In JavaScript, how do I set the input focus to a particular form field when a page is first loaded?

John Zukowski

In the onLoad event for the page, call the focus() method of the form field. It helps if you name the form and field.

For instance, the following will cause the second text field to get the input focus when the page is loaded:

<body onLoad="document.form.start.focus()">
<form name=form>
<input type=text name=other>
<input type=text name=start>