hello,
I nned help to find out what wrong with this code of mine. Basically, I need to dropdown box of USA states to match and selected a given state I entered. So far, I'd be able to match and get the right selectedIndex.value to alert, but cannot make the select box to change to the given state.
Thanks!
I nned help to find out what wrong with this code of mine. Basically, I need to dropdown box of USA states to match and selected a given state I entered. So far, I'd be able to match and get the right selectedIndex.value to alert, but cannot make the select box to change to the given state.
Code:
var testState = 'CA';
var stateObj = document.getElementById('shippingState');
for (var s=0; s<stateObj.length; s++) {
if (stateObj.options[s].value==testState) {
stateObj.selectedIndex = s;
}
}
Thanks!