Set Form focus : Focus « Form « JavaScript Tutorial






<html>
<head>
<title>Set Form focus</title>
<script type="text/javascript" language="javascript">
<!-- //
function SetFocus(){
    document.SimpleForm.FirstInput.focus();
}

function FindMaxAndMin(){
        SetFocus();
}

// -->
</script>
</head>
<body onload="SetFocus()">
<form name="SimpleForm">
<table>
<tr>
 <td width="25%" align="right">Enter first number:</td>
 <td><input name="FirstInput" type="text"></td>
</tr>
<tr>
 <td width="25%" align="right">Enter second number:</td>
 <td><input name="SecondInput" type="text"></td>
</tr>
<tr>
 <td width="25%" align="right">Enter third number:</td>
 <td><input name="ThirdInput" type="text"></td>
</tr>
<tr>
 <td width="25%" align="right">&nbsp;</td>
 <td><button type="Button" onclick="FindMaxAndMin()">
Click to calculate</button></td>
</tr>
</table>
</form>
</body>
</html>








10.19.Focus
10.19.1.Set Form focus