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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text field "Selected" ? 1

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
0
0
EU
Hi,
I am trying to have the cursor automatically inserted into a textfield when a page opens. Similar in working to the "Selected" aspect of a list/menu. Anyone got any ideas how this is achieved?

Cheers from Cheech I dont want to go to Chelsea!!!
 
Just focus in the textfield using JavaScript on the onLoad event of the body html tag.

Lets suggest that the text field is called "txtField" and is part of the form "form1". Do as follows:

In the body tag of the html code add the "onLoad" event, just to call the focus property of the "txtField" using some JavaScript:

<body onLoad=&quot;javascript:document.form1.txtField.focus();&quot; >

maybe there will be other statements or properties defined on the body tag, but the only thing to do is add the onLoad event as above...

Also, if the text field is not inside some form, (I wouldn't suggest that, cause you will have problems displaying it in NetScape) just don't put the word &quot;form1&quot;
in the sequence of the onLoad event. The rest remains the same.

Hope this helped you:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top