Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Dreamweaver

This chapter is from the book

FOCUS YOUR ATTENTION RIGHT HERE

Here is a simple little JavaScript used to give a specific field focus in a form when the page is loaded so that the user can start filling out the fields right away. Right+click (Ctrl+click) the <body> tag in the Tag Selector in the lower left of the Document window if you're using Design view and choose Edit Tag (if you're in Code view, get ready to modify the <body> tag). Here's the code to add to the <body> tag:

Replace theFormName with the exact name of your form and theFieldName with the exact name of the field in which you want the cursor to be positioned when the page loads. When I say exact, I mean it; make sure the casing is identical.

By the way, if an onload event is already present, you should add only the portion between the quotes and not a second onload attribute. Remember that functions must be separated by a semicolon, so if you put this at the start of an existing onload event you should be just fine.

  • + Share This
  • 🔖 Save To Your Account