Forums

This topic is locked

Make? Cursor to go in 1st text box atomatically

Posted 28 Oct 2002 17:02:41
1
has voted
28 Oct 2002 17:02:41 Don Thomas posted:
How do I go about making the cursor appear in the 1st text box of a from on a page after the page has loaded?

Don Thomas

Replies

Replied 29 Oct 2002 09:18:17
29 Oct 2002 09:18:17 Vince Baker replied:
This goes into the head of the script:

<script language="JavaScript">
function firstFocus()
{
if (document.forms.length > 0)
{
var TForm = document.forms[0];
for (i=0;i<TForm.length;i++)
{
if ((TForm.elements[i].type=="text"||
(TForm.elements[i].type=="textarea"||
(TForm.elements[i].type.toString().charAt(0)=="s")
{
document.forms[0].elements[i].focus();
break;
}
}
}
}
</script>

This goes into the body of the doc:

<BODY onLoad="firstFocus()">


Regards
Vince

Response.write("The best line of code you can ever use"

VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 29 Oct 2002 14:59:10
29 Oct 2002 14:59:10 Don Thomas replied:
Thanks Vince, Now the users of the City's Intranet Telephone directory love me again. The Code worked wonderfully!

Don Thomas

Reply to this topic