Let me start by saying I’m a noob to JavaScript.
What I’m trying to do for my website is have a select menu that shows the number of div’s that’s selected. I found a JS that I could do that with, but it only toggles, not change specifically what’s selected. So if you click the wrong one, it doesn’t work right. Here’s what I got:
[CODE]<body>
<script type=”text/javascript”>
function toggle_visibility(){
for(var i = 0,len = arguments.length;i < len; i++){
var e = document.getElementById(arguments[i]).style,d = e.display;
e.display = (d == “block”) ? “none” : “block”;
}
}
</script>
<select name=”select” id=”select”>
<option>0</option>
<option onclick=”toggle_visibility(‘1’);” >1</option>
<option onclick=”toggle_visibility(‘1′,’2’);”>2</option>
<option onclick=”toggle_visibility(‘1′,’2′,’3’);”>3</option>
<option onclick=”toggle_visibility(‘1′,’2′,’3′,’4’);”>4</option>
</select><br>
<div id=”1″ style=”display: none;”>Test1</div>
<div id=”2″ style=”display: none;”>Test2</div>
<div id=”3″ style=”display: none;”>Test3</div>
<div id=”4″ style=”display: none;”>Test4</div>
</body>
Any help would be appreciated, cause I’m lost.