I have searched and found lots on enabling/disabling form inputs, but nothing that matches my needs.
So here is my attempt, which isn’t working. Please help find where I’ve gone wrong and why it isn’t working. Thanks for taking a look.
I have a form with a dropdown with values 0-4. If value 0 is selected I want the checkboxes to be disabled. If value 1-4 is selected I want the checkboxes to be enabled.
[code]
<html>
<head><title>Disable with Dropdown Test</title>
<script>
function num_check(sel,cb) {
var aryVals = new Array(‘1′,’2′,’3′,’4’);
var makeDisabled = true;
for ( var i = 0; i < aryVals.length; i++) {
if( sel.options[sel.selectedIndex].value == aryVals[i])
makeDisabled = false;
}
cb.disabled = makeDisabled;
}
</script>
</head>
<body>
<form name=”form1″>
<div>
<p>Across Catgories:</p>
<div class=”top_space”>
<p>Remove <select name=”num” id=”num” class=”drop_down” onchange=”num_check(this,this.form1.list);”>
<option value=”0″>0</option>
<option value=”1″>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
<option value=”4″>4</option>
</select> items from these Categories:</p>
<input type=”checkbox” id=”cat1″ name=”list” value=”1″ /><label for=”cat1″>Summative</label><br />
<input type=”checkbox” id=”cat2″ name=”list” value=”2″ /><label for=”cat2″>Formative</label><br />
<input type=”checkbox” id=”cat3″ name=”list” value=”3″ /><label for=”cat3″>Homework</label><br />
<input type=”checkbox” id=”cat4″ name=”list” value=”4″ /><label for=”cat4″>Classwork</label><br />
</div>
</div>
</form>
</body>
</html>