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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Focus on this form 1

Status
Not open for further replies.
Apr 25, 2002
156
GB
Hi all,

Please can somebody show where to try the setfocus() as in Vbscript on the following page which is a login form

I want the textbox for username to receive the focus... after reading and trying all have not got this to work

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Please Log In...</title>
</head>

<body bgcolor="#C0C0C0">


<form action=loginHandler.asp method=post>
<p align="center">
&nbsp;
</p>
<p align="center">
<font color="#0000FF" size="4" face="Verdana">Please enter your username
and password<br>
to access the secure area of the intranet</font>
</p>
<div align="center">
<center>
<table border="1" width="60%">
<tr>
<td width="50%">
<p align="center"><font face="Verdana" color="#0000FF">Username:</font></td>
<td width="50%"><input type=text name='username' size="20" style="color: #0000FF; font-size: 12pt; font-weight: bold; font-family: Verdana"></td>
</tr>
<tr>
<td width="50%">
<p align="center"><font face="Verdana" color="#0000FF">
Password:</font></td>
<td width="50%"><input type=password name='password' size="14" style="font-family: Verdana; font-size: 12pt; color: #0000FF"></td>
</tr>
</table>
</center>
</div>
<p align="center">
&nbsp;
</p>
<p align="center">
<input type=submit Value='Log In'><BR>
</p>
</form>

<hr>
<p align="center">&nbsp;</p>

</body>
</html>

regards in advance
Murray
 

Try changing this:

Code:
<body bgcolor="#C0C0C0">

to this:

Code:
<body bgcolor="#C0C0C0" onload="document.forms[0].username.focus();">

If that fails, add a tabIndex attribute to your "username" input box:

Code:
<input type="text" name="username" size="20" tabIndx="1">

Incidentally, consider using CSS to remove the duplication of font and colour styles on the input boxes.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top