Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

focus() on load or refreshing a form?

Posted on 2003-12-02
4
Medium Priority
?
462 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 500 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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…
Suggested Courses

810 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