Text version | Next example | Back to index |
HTML does not have a command to set the focus in a field, but JavaScript does.
<HEAD>
<TITLE>Focus Example</TITLE>
<SCRIPT type="text/javascript">
function setFocus()
{
document.focus.firstName.focus();
}
</SCRIPT>
</HEAD>
<BODY onload="setFocus()">
<P>
<FORM method="post" name ="focus" action="">
First name: <INPUT type="text" name="firstName">
Last name: <INPUT type="text" name="lastName">
</FORM>
</BODY>
</HTML>