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

Set field/entry focus 1

Status
Not open for further replies.

rjs

MIS
Apr 6, 1999
632
US
On a Cold Fusion data entry form, is there a way to put the cursor in the first data entry field? I'm pretty sure I can do this with Java, but would like to avoid that if possible.
 
Use javascript in the &lt;body&gt; tag of your page.<br>
<br>
Use this syntax:<br>
&lt;body onload=&quot;document.myform.myfield.focus();&quot;&gt;<br>
<br>
With the code above you have to give your form and field a name eg name=&quot;myform&quot; and name=&quot;myfield&quot;.<br>
With the next bit of code it will set the focus to the first element in the first form on your page. So no need to name your form, or specify its name in the code.<br>
<br>
&lt;body onload=&quot;document.forms[0].elements[0].focus();&quot;&gt;<br>
<br>
This should work on Netscape 3 upwards.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top