Javascript Show/Hide correct div

samwan

New Member
I have a page with a drop down with 3 items:\[code\]<select name="orderOption" id="orderOption"><option value="http://stackoverflow.com/questions/11891882/1">Item 1</option><option value="http://stackoverflow.com/questions/11891882/2">Item 2</option><option value="http://stackoverflow.com/questions/11891882/3">Item 3</option> </select>\[/code\]Currently there is Javascript to show or hide a div with the appropriate class, based on that selection. \[code\]function orderOptionChanged() { var e = document.getElementById("orderOption"); var orderOption = e.options[e.selectedIndex].value; if (orderOption == "1") { $('.OrderOption1').show(); $('.OrderOption2,.OrderOption3,').hide(); }\[/code\]This works fine for just the 3 of them, but now they want 25 of them. I need a way to select only the one option without having to write it all out. I've never worked with Javascript before, so this is all new to me.
 
Back
Top