JavaScript Focus on a textbox, Problems giving focus to a textbox |
JavaScript Focus on a textbox, Problems giving focus to a textbox |
supernashwan |
Feb 25 2008, 06:47 AM
Post
#1
|
Group: Members Posts: 3 Joined: 25-February 08 Member No.: 5,043 |
Hi,
I have no idea what I'm doing wrong here but this code works in FF and not in IE (6 or 7). I'm simply trying to give the 2nd textbox focus. Note, if you uncomment the alert and try in IE again then it suddenly works, any ideas why??? Code (you can simply cut this out and save in a text file, drop it in FF and IE and see what i mean): <html> <head> <title></title> </head> <body> <form> <input type="text" id="mytext1" name="mytext1" value="1"><br> <input type="text" id="mytext2" name="mytext2" value="2"><br> <input type="text" id="mytext3" name="mytext3" value="3"><br> </form> <script language="javascript" type="text/javascript"> //window.alert("hello"); var mytext = document.getElementById("mytext2"); mytext.focus(); </script> </body> </html> Any help with this would be much appreciated. Cheers Paul. |
Lo-Fi Version | Time is now: 26th April 2024 - 07:55 PM |