|
-
Aug 27th, 2001, 01:47 PM
#1
Thread Starter
Hyperactive Member
A simple question, I think...
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.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Aug 27th, 2001, 01:59 PM
#2
Frenzied Member
you do it in javascript
document.yourFormName.yourTextName.focus();
-
Aug 27th, 2001, 02:56 PM
#3
Thread Starter
Hyperactive Member
Stupid question, but need to know...
where do I put this line of code??? Do I have to create a function or what do I have to do?
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Aug 27th, 2001, 03:59 PM
#4
Addicted Member
You can also do it in VBScript, but that is only IE specific, unless they made Netscape better recently.
VB Code:
<body onLoad="txtField1.focus()">
This should work for both javascript and vbscript... this will when the form loads, set the focus to txtField1 on your html/asp page.
You may need to specify the form name if you are using a form on your page. For example:
VB Code:
<body onLoad="form1.txtField1.focus()">
Hope it helps.
Michael
Application/Web Developer
Visual Basic 6.0 SP5
Active Server Pages
Oracle 9i
- I'm going to live forever, or die trying!
-
Aug 28th, 2001, 10:44 AM
#5
Thread Starter
Hyperactive Member
THANX!
Thank you, Michael & Sebs. Michael, the second line of code:
Code:
<body onLoad="form1.txtField1.focus()">
is the one that worked.
Thanks to you both for your input.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|