How to Set a field to get focus on startup

D

Darren Clark

could try a generic option

function init()
{
try
{
document.forms[0].elements[0].setFocus();
}
}


tfs said:
How do I set a field on my screen to get focus when the page opens?

Thanks,

Tom
 
T

tfs

I tried the following, but it didn't seem to work.
<script language="JavaScript" >
document.getElementById("tfPassword").focus();
</script>

<div align="center">
<p><span class="HeaderText">Please enter the password to process
these pages</span></p>
<form name="_ctl1" method="post"
action="TMPluy1i8bi.aspx" id="_ctl1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTU3MDA0ODk5NDs7PhcziXEHc3pyzzr86qHlt50NG4LD" />
<table width="230" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="35%"
class="BodyText">Password: said:
<td width="65%"><input
name="tfPassword" type="text" id="tfPassword" /> said:

I am running this in an asp.net page running vb.net. Is there a
problem running javascript with this?

Thanks,

Tom.
 
H

Holly

I used this:
http://www.reflectionit.nl/InitialFocus.aspx

Holly
-----Original Message-----
Check out this faq,
http://www.extremeexperts.com/Net/CodeSnippets/SettingFoc ustoElementAfterPos
tback.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



How do I set a field on my screen to get focus when the page opens?

Thanks,

Tom


Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------------------------------------------- ---

------------------------------------------------------- ---
color]


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top