<select name="feature1"> <option value="1">Enable</option> <option value="0">Disable</option> </select> <input type="checkbox" name="feature2" /> <input type="checkbox" name="feature3" />
Как отключить входы «feature2» и «featured3», когда выбрано «disable» в «feature1»?
Спасибо
Это автоматически включает элементы снова, когда выбрано «Включить», что, я полагаю, также является тем, что вы хотите.
Я предполагаю, что у вас есть идентификаторы, идентичные именам ваших элементов, для простоты
jQuery('#feature1').change(function() { jQuery("#feature2, #feature3").attr("disabled", jQuery(this).val() == '0'); });
Добавьте несколько идентификаторов для ваших элементов, затем:
$('#feature1').change(function() { if(this.value === "0") { $('#feature2').attr('disabled', 'disabled'); $('#feature3').attr('disabled', 'disabled'); } });
<script type="text/javascript"> abc(val){ if (val.value=="0"){ document.getElementByID("").disabled= true; document.getElementByID("").disabled= true; }else{ document.getElementByID("").disabled= false; document.getElementByID("").disabled= false; } } </script> <select name="feature1" onchange="abc(this)"> <option value="1">Enable</option> <option value="0">Disable</option> </select> <input type="checkbox" name="feature2" id="feature2" /> <input type="checkbox" name="feature3" id="feature3" />