Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1611 How do I position the cursor on the first field of the first form when a page loads?

You are here: irt.org | FAQ | JavaScript | Form | Q1611 [ previous next ]

Using a named form and a named form field:

<body onLoad="document.myForm.myField.focus()">

<form name="myForm">
<input type="text" name="myField">
</form>

When the form and field names are not known then:

<body onLoad="document.forms[0].elements[0].focus()">

<form>
<input type="text">
</form>

©2018 Martin Webb