Simple Tricks for More Usable Forms [JavaScript & DHTML Tutorials]

Simple Tricks for More Usable Forms [JavaScript & DHTML Tutorials]
You will certainly have encountered our first trick before; it’s used by Google, the world’s most popular search engine. Whenever you load up www.google.com, your cursor jumps straight to the search box, ready for you to enter your query. It happens so fast you may not even have thought about it, but, in fact, it works equally well in any situation in which the primary purpose of a page is to fill in a form. It can be done in a number of different ways, each of which assumes that the form element you want to focus on has an id attribute set to “myfield”:

<body onload=”document.getElementById(‘myfield’).focus()”></body>