473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jul 20 '05 #1
3 15632
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
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." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
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.

Jul 20 '05 #3
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." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
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.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JCO | last post by:
I have a text box, on my form that I cant get the focus on. I'm using it as shown: <head> <body onload=document.getPassword.txtPasswordName.focus()> </head> Where getPassword is the form &...
6
by: Csaba | last post by:
I'd like to have the cursor in the login form's username input text field when users load the login page. It works fine with the following implementation: <body...
6
by: Brian | last post by:
I'm trying unsuccessfully to use a variable in a script that changes focus. Depending on which link a user follows (navigates via keyboard or clicks), I'd like to change the focus to an input...
1
by: Adi | last post by:
I'm trying to do default focus on checkbox,its work fine but the problem is that the user cannot know where is the focus (there isn't visual sign and on the other hand if you press on the tab...
5
by: Rune Runnestø | last post by:
How do I focus the cursor in the input field 'numberField' when accessing this jsp-file (or html-file) ? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
5
by: feng | last post by:
Hi, I have a aspx page that contains a textbox. When the page loads, it's always the browser's address bar or other browser controls has the focus. What I want however, is to let the textbox...
4
by: GTi | last post by:
Is it possible to have a generic script that set the input focus on the first valid element in a document (not hidden or disabled) ? This script is at the end of a document, but don't work. ...
5
by: linuxnooby | last post by:
This is a simple question but it is doing my head in all i want is a form text field to be focused when the page loads. Works in IE6 but not in Firefox 1.6 <body > <form...
2
by: yawnmoth | last post by:
Say I have two input elements and that I wanted to make it so that when the first ones input was what it should be, the focus would automatically be shifted to the next input element. ie....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.