|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem with "focus()"
Hi,
Instead of putting the focus on the first field, I get the focus on the second field!!!! Here my code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function tab(obj) { // alert("test"); var lettre1= event.keyCode; if (lettre1 == 9) { obj.form.elements[0].focus(); alert ("valeur="+obj.form.elements[0].value); } } </script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans nom</title> </head> <body> <form name="formulaire" action=""> <input type="text" name="champ1" id="champ1" maxlength="6"/> <input type="text" name="champ2" id="champ2" maxlength="6"/> <input type="text" name="champ3" id="champ3" maxlength="6"/> <input type="text" name="champ4" id="champ4" maxlength="6" onkeyDown="tab(this);"/> <input type="hidden" name="champ5" id="champ5" maxlength="6"/> </form> </body> </html> Do you have any suggestion? Thanks Fh |
|
#2
|
|||
|
|||
|
That is because you programmatically moved the focus to the first field and then the browser responded to the tab key and moved the focus to the next field.
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|