The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

The second option is based on the number of form elements on the page. It also uses the element id.

Javascript can address form elements by counting them and then performing a script on the first, second, third... element.
*** Javascript starts counting from 0, so the first form element will be number 0, the second will be number 1, etc...) ***

If the text field is the first form element (#0) on the page then you can address it like this.

document.forms[0].firstfield.focus()

You can wrap this into a function also as mentioned before or put it straight into the body and attaching it to an onload event.

Both these methods can be written to be more flexible and reusable.

Fwiw, you don't even need to attach it to the onload event (or any other event).
As long as the javascript command line is *after* the line of code containing the textfield, then it will still focus it.
For an example of this, just check the code at Google.co.uk or Hotmail.com. They both use javascript to set the focus on their forms.