Answers
Sep 05, 2006 - 07:17 PM
<br>function setFocus() <br>{ <br>document.getElementById("txtName").focus() <br>} <br>
where "txtName" is the value in the name attribute of your text box.
and in your tag add
Hope this helps!
Cheers
Peter
Sep 08, 2006 - 07:51 AM
You will need to replace the text 'username' with the actual name of the your username input.
<br> var inputs = document.getElementsByTagName('input'); <br> for (var i = 0; i < inputs.length; i++) <br> { <br> if(inputs[i].name =='username') <br> { <br> inputs[i].focus(); <br> } <br> } <br> <br>
For a very simple working example, just save this below as a html file and load it in your local browser. Notice the location of the script after the body close and before the close of the html tag.
<br> var inputs = document.getElementsByTagName('input'); <br> for (var i = 0; i < inputs.length; i++) <br> { <br> if(inputs[i].name =='username') <br> { <br> inputs[i].focus(); <br> } <br> } <br> <br>
Oct 04, 2006 - 11:07 AM



Add New Comment