Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus on text fields 2

Status
Not open for further replies.

bjohnson

Programmer
May 3, 2001
4
US
This is probably a real bonehead question, but I can't find the answer in any of my HTML books. All I want to do is to be able to insert the cursor's focus in a specified text box of my choice.

For example, I have a simple page with one text field and one submit button:

<INPUT TYPE=&quot;text&quot; NAME=&quot;Test&quot;>
<BR>
<INPUT TYPE=&quot;submit&quot; NAME=&quot;Submit&quot;>

So, when the user goes into this page, I want the cursor to be in the &quot;Test&quot; text box (currently, the user must first click in the text box for the cursor to appear).

I am assuming that I am just missing one GIANT step. Thanks!
 
does this work?


Code:
<body onLoad=&quot;document.getElementById(&quot;Test&quot;).focus();&quot;>
Klae

You're only as good as your last answer!
 
Hi,

keep in mind that getElementById don't works with Netscape 4.x browser, only NS6. but you can do

<body onload=&quot;document.formName.FieldName.focus()&quot;>

hope this helps,
Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top