Columbo
08-16-2009, 01:04 AM
I have used the following code to force cursor into the first field of a form but it doesn't work for some reason. The code does not flag any errors but it displays the form with no visible cursor. You have to click in the first field of the form to get the cursor. Can anyone suggest why?
<html>
<head>
<title>Data Entry Form</title>
</head>
<body onload="document.dataform.siteName.focus();">
<center>
<br /><br /><br /><br />
<table width="365px" height="200px" cellpadding="10" style="border: 1px solid #CC0000;">
<form name="dataform" method="POST" action="addsite.php">
<tr><td>
Site Name:
<INPUT type="text" name="siteName" size="40"> <br />
Username:
<INPUT type="text" name="user" size="10"> <br />
Password:
<INPUT type="text" name="password" size="20"> <br />
</td></tr>
<INPUT type="hidden" name="siteName" value="<?php echo $_POST['siteName']; ?>">
<INPUT type="hidden" name="user" value="<?php echo $_POST['user']; ?>">
<INPUT type="hidden" name="pass" value="<?php echo $_POST['password']; ?>">
<tr><td align="center">
<INPUT type="submit" value="Add to database" name="Button1">
<INPUT type="RESET" value="Reset">
</td></tr>
</form>
</table>
</center>
</body>
</html>
Thanks
<html>
<head>
<title>Data Entry Form</title>
</head>
<body onload="document.dataform.siteName.focus();">
<center>
<br /><br /><br /><br />
<table width="365px" height="200px" cellpadding="10" style="border: 1px solid #CC0000;">
<form name="dataform" method="POST" action="addsite.php">
<tr><td>
Site Name:
<INPUT type="text" name="siteName" size="40"> <br />
Username:
<INPUT type="text" name="user" size="10"> <br />
Password:
<INPUT type="text" name="password" size="20"> <br />
</td></tr>
<INPUT type="hidden" name="siteName" value="<?php echo $_POST['siteName']; ?>">
<INPUT type="hidden" name="user" value="<?php echo $_POST['user']; ?>">
<INPUT type="hidden" name="pass" value="<?php echo $_POST['password']; ?>">
<tr><td align="center">
<INPUT type="submit" value="Add to database" name="Button1">
<INPUT type="RESET" value="Reset">
</td></tr>
</form>
</table>
</center>
</body>
</html>
Thanks