I have a dropdown menu and I cannot figure out how to make a javascript function select a drop down menu option. I have tested the output of the variables and they are all corre
Change the line that reads:
document.getElementById("stateSelect").selected = true;
to:
document.getElementById("stateSelect").selectedIndex = i;
Alt. you can set selected to the actual option: select.options[i].selected = true;
...
var select = document.getElementById("stateSelect");
for(var i = 0;i < select.options.length;i++){
if(select.options[i].value == c ){
select.options[i].selected = true;
}
}
...