faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 21 people (48%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I get a form page to load with the cursor already flashing in the first text box field

Jun 5th, 2002 07:23
jsWalter, Ade Bedford,


This is what I use...
// Set focus to the first item
function focusFirstItem()
{
	// This will only work IF we have
	// an element to focus on
	if ( document.forms[0] )
	document.forms[0].elements[0].focus();
}
This example this will set FOCUS on the first item in a Form, 
regardless what type it is.
If we take the question asked literally, and we nedd to to FOCUS on the 
first TEXT box...
Think of this as an excersise to see how to modify this example to 
FOCUS on the first TEXT box only.
Ade, please hand in your homework by the end of the week.  ;)
Class dismissed.
Walter