get focus of form elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hadi S.

    get focus of form elements

    Hi,

    i want to control the 'Enter' key to set focus to the next element in
    the form(instead of 'Tab'). and i want to know which element had the
    focus when the Keypress even of the form is called. how can i get
    that?

    Thanks

    Hadi Sharghi
  • Evertjan.

    #2
    Re: get focus of form elements

    Hadi S. wrote on 09 aug 2003 in comp.lang.javas cript:
    [color=blue]
    > i want to control the 'Enter' key to set focus to the next element in
    > the form(instead of 'Tab'). and i want to know which element had the
    > focus when the Keypress event of the form is called. how can i get
    > that?
    >[/color]

    <input id="myinput"
    onkeydown="if (event.keyCode= =13)
    {alert(this.id) ;event.keyCode= 9}">

    IE6 tested, other browsers need another event handling.

    Hadi, this will change the standard execution so many will object to that.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Hadi S.

      #3
      Re: get focus of form elements

      Hi,

      the code didn't work in my page(Windows, IE6). when i press Enter key,
      it will pop up and messagebox, and then submit the form!

      Hadi Sharghi


      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message news:<Xns93D295 FCB5C80eejj99@1 94.109.133.29>. ..[color=blue]
      > Hadi S. wrote on 09 aug 2003 in comp.lang.javas cript:
      >[color=green]
      > > i want to control the 'Enter' key to set focus to the next element in
      > > the form(instead of 'Tab'). and i want to know which element had the
      > > focus when the Keypress event of the form is called. how can i get
      > > that?
      > >[/color]
      >
      > <input id="myinput"
      > onkeydown="if (event.keyCode= =13)
      > {alert(this.id) ;event.keyCode= 9}">
      >
      > IE6 tested, other browsers need another event handling.
      >
      > Hadi, this will change the standard execution so many will object to that.[/color]

      Comment

      • Hadi S.

        #4
        Re: get focus of form elements

        Hi,

        the code didn't work in my page(Windows, IE6). when i press Enter key,
        it will pop up and messagebox, and then submit the form!

        Hadi Sharghi


        "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message news:<Xns93D295 FCB5C80eejj99@1 94.109.133.29>. ..[color=blue]
        > Hadi S. wrote on 09 aug 2003 in comp.lang.javas cript:
        >[color=green]
        > > i want to control the 'Enter' key to set focus to the next element in
        > > the form(instead of 'Tab'). and i want to know which element had the
        > > focus when the Keypress event of the form is called. how can i get
        > > that?
        > >[/color]
        >
        > <input id="myinput"
        > onkeydown="if (event.keyCode= =13)
        > {alert(this.id) ;event.keyCode= 9}">
        >
        > IE6 tested, other browsers need another event handling.
        >
        > Hadi, this will change the standard execution so many will object to that.[/color]

        Comment

        Working...