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 strongm 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 form field in ASP page

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi!

I wonder, what would be a good way to set focus on some formfield. The problem is that I already have ..body onload = .. - method in my page for navigation bar or can I add two onload's to it?

What would be the best way to give focus on some form field?

Thank you!
 
It's not posible to use more then one onload event but u could use the function that u have to call another function or just put the code like bellow...
U should use the function in your onload event
<body onload=&quot;doLoad()&quot;>


function doLoad()
{
//put your old code here
document.Myform.MyTextbox.focus();
};

hope this help u...
________

George
 
Just out of interest, you can only have one onload event, but you can have more than one thing happening in that event. You can add more items to the same onload event by seperating them by using a semi-colon
e.g.
<i>onload=&quot;popupWin('mypage.htm');theform.name.focus()&quot;</i>

but I don't think it will allow things like alert boxes.

It is neater and easier to edit if you put them in a function though.
 
Or I have found that you can add the following to the bottom of your script:

<HTML>
<BODY>
.....Some Code, forms, etc......
<script Language=VBScript>
MyForm.ElementName.focus
</script>
</BODY>
</HTML>

Happy Coding! Tazzmann
 
eg:

<form name=MijnForm>
One: <input type=text name=fOne><br>
Two: <input type=text name=fTwo><br>
Three: <input type=text name=fThree><br>
<form>

<SCRIPT language=JavaScript>MijnForm.fOne.focus()</SCRIPT>




br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top