Solved

focus() on load or refreshing a form?

Posted on 2003-12-02
4
450 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
ID: 9863214
<body onload="document.Form1.yourField.focus();">
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9863216
where document.Form1 is your form
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9863242
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
ID: 9863433
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

910 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

22 Experts available now in Live!

Get 1:1 Help Now