I have a form with a multiple choice field A
<select multiple="multiple" name="A"></select>
and a boolean checkbox B
<input type="checkbox" name="B" />
I want to disable field A if field B is checked. If field B gets unchecked, I want to re-enable field A again.
I tried this:
$('input[name="B"]').toggle(function() {
$('select[name="A"]').addClass('uneditable-input').attr('disabled', 'disabled');
}, function() {
$('select[name="A"]').removeClass('uneditable-input').removeAttr('disabled');
});
However, this does not work. Instead, it makes the checkbox disappear from my webpage. How can I achieve what I described above?