Hi again!
I wanted to know how to set the focus to a specific textbox when an ASP page opens. I have an ASP that, when it is loaded, the cursor/focus is not on the textbox. I need for it to be. Any ideas?
Thanks in advance.
Printable View
Hi again!
I wanted to know how to set the focus to a specific textbox when an ASP page opens. I have an ASP that, when it is loaded, the cursor/focus is not on the textbox. I need for it to be. Any ideas?
Thanks in advance.
you do it in javascript
document.yourFormName.yourTextName.focus();
where do I put this line of code??? Do I have to create a function or what do I have to do?
You can also do it in VBScript, but that is only IE specific, unless they made Netscape better recently.
This should work for both javascript and vbscript... this will when the form loads, set the focus to txtField1 on your html/asp page.VB Code:
<body onLoad="txtField1.focus()">
You may need to specify the form name if you are using a form on your page. For example:Hope it helps.VB Code:
<body onLoad="form1.txtField1.focus()">
Michael
Thank you, Michael & Sebs. Michael, the second line of code:is the one that worked.Code:<body onLoad="form1.txtField1.focus()">
Thanks to you both for your input.