Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting focus to a textbox on a form

Status
Not open for further replies.

DavidArchibald

IS-IT--Management
Oct 29, 2000
20
0
0
NZ
I'm being a bit lazy here ... the help in this forum has been excellent so far.

I'd like to set focus to a textbox on a form when the page loads. I'd prefer to use ASP rather than Javascript.

Is this possible? If so, how is it done?

Cheers
 
Don't think you can use just ASP:

<form name=&quot;formname&quot;>
<input name=&quot;benluc&quot; type=&quot;text&quot;>
<script>document.formname.benluc.focus()</script>
</form>

should work jared@aauser.com -
 
You can set the taborder in HTML or just you client-side javascript. The ASP page can still be used to determine which box to initially focus on by having it generate that part of the javascript.
Wushutwist
 
Use a javascript function that gets called in the body tag of the document. Add this to the body tag:
Onload=&quot;funcFocus()&quot; (call it whatever you want).

Then create the funcFocus() as:

function funcfocus()
{
self.focus();document.frmname.fieldname.focus();
}

Substitute the name of the form and the name of the text field...works like a charm.

Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top