Set a specific listbox/combobox value in JavaScript

Loops through all the options and stops when if finds the desired value, in this case, "Finland" and marks it as selected.
JavaScript


for ( i=0 ; i<document.forms[0].HomeCountry.length ; i++ ){
	if (document.forms[0].HomeCountry.options[i].text=='Finland') {
		//select the index i	
		document.forms[0].HomeCountry.options[i].selected = true
	}
}

Posted by fbrefere001 on Friday April 1, 2005