Solved

focus() on load or refreshing a form?

Posted on 2003-12-02
4
455 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html form and modal / img src -problem 3 30
Media Queries  not Firing 6 17
Ouput in html in powershell 2 19
..ignore the Question 1 7
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
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 …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

861 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