<script language="JavaScript">
<!-- Begin
function toForm() {
document.form1.username.focus();
}
</script>
Replace 'username' in the script with the field name of which you want to
place the focus. Also, give the form a name: <form name="form1" ...>
Or you could make the cursor jump to the first input field for any form on on any page like this (note that this jumps to the first form on the page which generally works for me but probably won't work if you have something like a search box at the top of every page):
<script type="text/javascript">
window.onload = function() {
if (document.getElementsByTagName != null) {
if(document.forms[0] != null && document.forms[0].getElementsByTagName("input")[0] != null) {
document.forms[0].getElementsByTagName("input")[0].focus();
}
}
}
</script>
- Jamie
-----Original Message-----
From: l Burnerheimerton [mailto:lburnerheimerton@yahoo.com]
Sent: 30 March 2005 3:53 pm
To: pear-general@lists.php.net
Subject: [PEAR] how to make (using javascript or otherwise) cursor go to
username field in AUTH when page loads?
I am using AUTH and like it. I want to make it so
that when the page loads, the cursor is in the first
field. Now you have to click in that field.
Thanks.
function loginFunction()
{
...
echo "<input type=\"text\" name=\"logName\"><BR>";
echo "<input type=\"pass\" name=\"pass\"><BR>";
...
}