Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #41

How can I set a particular form field to have the cursor when the page first loads?

The Answer

Prepared Oct. 2000 by Gerry Jacobsen, PVII

To set a particular form field to contain the cursor position when the page first opens, use the following script:

<form>
  ...all of the field code>
<script>
  // set focus to form field
  document.forms[0].MyFormFieldName.focus();
  document.forms[0].MyFormFieldName.select();
</script>
</form>

Insert this INSIDE the form tag, preferably just before the ending </form> tag. MyFormName should contain the name of the input field you want to assign focus to.

 

Back to the questions list