Forum Moderators: open
var select = document.GetElementById('id');
for (var i = 0; i < select.length; i++) {
if (select.options[i].value == desiredValue) {
select.options[i].selected = true;
} else {
select.options[i].selected = false;
}
}
But it only works in IE. Firefox js console complains that select doesn't have any properties. Any ideas?
The second idea is that it's best to avoid variable names that clash with other objects - so change "select" to something safer like "mySelect".