Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a select box

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
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.
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!
 
Nevermind, I could just kick myself for this stupid mistake.

Basically, I called to display the shipping State instead of the billing State. The change was made but I didn't notice until now.

Sorry all for this waste of space. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top