我经历了一些通过javascript启用/禁用多个html元素的代码:
<script type="text/javascript">
function enableDisable(bEnable, text_no1, text_no2, opt_no1, opt_no2){
document.getElementById(text_no1).disabled = !bEnable
document.getElementById(text_no2).disabled = !bEnable
document.getElementById(opt_no1).disabled = !bEnable
document.getElementById(opt_no2).disabled = !bEnable
}
</script>
<label for="toggler"><input type="checkbox" id="toggler" autocomplete="off"
checked="false"
onclick="enableDisable(this.checked, 'text_no1','text_no2','opt_no1','opt_no2')";>
Toggler</label>
<br>
<input type="text" name="text_no1"><br>
<input type="text" name="text_no1"><br>
<select name="opt_no1">
<option>1</option>
</select>
<select name="opt_no2">
<option>1</option>
</select>