SWE 432 JavaScript example: Focus Example

Text version Next example Back to index

HTML does not have a command to set the focus in a field, but JavaScript does.

First name:         Last name:

<title>Focus Example</title>
   <script type="text/javascript">
     function setFocus()

<body onload="setFocus()">

<form method="post" name ="focus" action="">
   First name: <input type="text" name="firstName">
   &nbsp; &nbsp; &nbsp; &nbsp;
   Last name: <input type="text" name="lastName">