Long time browser, first time poster.
What I'd like to do is have a user select the number of weeks to display in a dropdown menu, and then reveal that many divs. Right now I have it setup where I can reveal one div or all, but I'd like to do it for the previous divs.
Right now I have:
<SELECT name="number_of_weeks" id="number_of_weeks">
<OPTION value = "week1">1</OPTION>
<OPTION value = "week2">2</OPTION>
<OPTION value = "week3">3</OPTION>
</SELECT>
<div id = "week1" class = "weekmenu">
Week 1 </br>
</div>
<div id = "week2" class = "weekmenu">
Week 2 </br>
</div>
<div id = "week3" class = "weekmenu">
Week 3 </br>
</div>
And for the javascript:
$(document).ready(function () {
$('.weekmenu').hide();
$('#week1').show();
$('#number_of_weeks').change(function () {
$('.weekmenu').hide();
$('#'+$(this).val()).show();
});
});
The output should be something like this: If week1 is selected only the week1 div is shown. If week 2 is selected, both the week1 and week2 divs are shown. If week 3 is selected the week1, week2, and week3 divs are shown.
I've been banging my head over this...I tried creating some nested divs but it didn't work out quite right. I also tried to give multiple divs their own classes, and then try to show those.
JSFiddle: http://jsfiddle.net/meRcr/21/
Any help is appreciated!