A coder's home for Marc "Foddex" Oude Kotte, who used to be located in Enschede, The Netherlands, but now in Stockholm, Sweden!
Originally posted at Mon 03-08-2009 14:15:06
, in the nerd stuff category.
or even here
var s = document.form.mySelect;
for (var i=0; i=s.options.length; ++i)
s.selectedIndex = i;
However, there's a new shiny hammer to do this, and it works in Firefox 3.5 and Internet Explorer 6 and 8 (haven't tested any other browsers): simply set the value property of the select!
document.form.mySelect.value = valueToBeSelected;
Lot less code aye!
Confirm whether or not it works in your browser by clicking the following buttons: