Solved

focus() on load or refreshing a form?

Posted on 2003-12-02
4
448 Views
Last Modified: 2010-04-09
I have a form.htm that a user will enter several blanks of information. These fields are in a table format one above the other.
 
When I load my webpage, the focus is on the third field and I can't figure out why.

Can someone tell me how to code so the focus is in the name field, which is the first entry blank the user should start with.

Thanks a bunch.
0
Comment
Question by:needexpert
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 125 total points
Comment Utility
<body onload="document.Form1.yourField.focus();">
0
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
where document.Form1 is your form
0
 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
You can also use the CSS label attribute - this was specified to allow users to tab properly from one element to the next...

<html>
<head>
<title>Hello</title>
<style type="text/css">
<!--
form  {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 14px;
      color: #000000;
      }

label {
      float: left;
      width:200px;
      clear:both;
      }
//-->
</style>
</head>
<body>
<form>
<label for="username">Username:</label> <input type="text" sixe="10" name="username"><br />
<label for="password">Password:</label> <input type="text" sixe="10" name="password"><br />
<label for="name">Name:</label> <input type="text" sixe="10" name="name"><br />
<label for="address">Address:</label> <input type="text" sixe="10" name="address"><br />
</form>
</body>
</html>
0
 

Author Comment

by:needexpert
Comment Utility
Thanks, let me try it... I actually have a bigger problem now, which I just opened up another question for because of its length. I will let you know if it worked.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now