Enable or Disable Listbox by selection of radio buttons
Change the enable or disable state of the two listboxes by Clicking the radio buttons
Student
HTML
Student <select id=student1>
<option value='Alex'>Alex</option>
<option value='Raju'>Raju</option>
<option value='Raman'>Raman</option>
</select>
<select id=student2>
<option value='Alex'>Alex</option>
<option value='Raju'>Raju</option>
<option value='Raman'>Raman</option>
</select>
<br><br>
<input type='radio' name='options' id='opt1' value='option1' >Disable one
<input type='radio' name='options' id='opt1' value='option2' >Disable both
<input type='radio' name='options' id='opt1' value='option3' >Disable none
JQuery
<script>
$(document).ready(function() {
$("input:radio[name=options]").click(function() {
var opt= $(this).val();
if(opt=='option1'){
$('#student1').attr('disabled', true);
}
/////
if(opt=='option2'){
$('#student1,#student2').attr('disabled', true);
}
/////
if(opt=='option3'){
//$('#student1,#student2').prop('disabled',false);
$('#student1,#student2').attr('disabled',false);
}
/////
})
});
</script>