Checking for focus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christoph Weber

    Checking for focus

    Hello,
    is there a function with which I can find out if a form element has the
    focus?
    Something like:

    function ReactIfFocus()
    {
    for(var i=0; i<10; i++)
    if( HasFocus(docume nt.forms[0].elements[i])
    makeSomething() ;
    }

    I need the function to move the focus to the next field.

    Thanks
    Christoph


  • Martin Honnen

    #2
    Re: Checking for focus



    Christoph Weber wrote:
    [color=blue]
    > is there a function with which I can find out if a form element has the
    > focus?
    > Something like:
    >
    > function ReactIfFocus()
    > {
    > for(var i=0; i<10; i++)
    > if( HasFocus(docume nt.forms[0].elements[i])
    > makeSomething() ;
    > }
    >
    > I need the function to move the focus to the next field.[/color]

    There are event handlers onfocus and onblur that let you react to a
    change of focus.
    IE also has
    if (document.activ eElement == document.forms[0].elements[i])
    see


    --

    Martin Honnen


    Comment

    • Christoph Weber

      #3
      Re: Checking for focus

      Danke !!
      So geht es.


      Comment

      • Shawn Milo

        #4
        Re: Checking for focus

        "Christoph Weber" <christoph.webe r@im-achental.de> wrote in message news:<2g92esFia 5U1@uni-berlin.de>...[color=blue]
        > Hello,
        > is there a function with which I can find out if a form element has the
        > focus?
        > Something like:
        >
        > function ReactIfFocus()
        > {
        > for(var i=0; i<10; i++)
        > if( HasFocus(docume nt.forms[0].elements[i])
        > makeSomething() ;
        > }
        >
        > I need the function to move the focus to the next field.
        >
        > Thanks
        > Christoph[/color]


        I did some quick Googling, and couldn't find anything like that.
        What are you trying to do? The only suggestion I found is to
        keep track of it or fire the desired function on the onfocus event.

        Shawn

        Comment

        Working...