get focus of form elements

H

Hadi S.

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
 
E

Evertjan.

Hadi S. wrote on 09 aug 2003 in comp.lang.javascript:
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?

<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.
 
H

Hadi S.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top