[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

focus() on load or refreshing a form?

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
needexpert
Asked:
needexpert
  • 2
1 Solution
 
bobbit31Commented:
<body onload="document.Form1.yourField.focus();">
0
 
bobbit31Commented:
where document.Form1 is your form
0
 
seanpowellCommented:
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
 
needexpertAuthor Commented:
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now