dimanche 26 février 2017

uncheck all check boxes other then one when clicked on a particular checkbox

I am working on checkboxes. Say I have three checkboxes:

<input type="checkbox" class="otherCheckboxes" id="checkbox1" value="1" /> 1
<input type="checkbox" class="otherCheckboxes"  id="checkbox2" value="2" /> 2
<input type="checkbox" id="checkbox3" value="No Entry" /> No Entry

Now if i check "No Entry" check box other checkboxes should be disabled if they are checked. And if i check again on other checkboxes when "No Entry" is checked, No Entry should be unchecked. i am trying to implement this using javascript and jquery.

i have tried:

$('#checkbox3').click(function() {
if ($(this).is(':checked')) {
    $('.otherCheckboxes').attr('checked', false);
} 

but this is not functioning according to the above requirement. Need some help resolving this issue Please. thanks in advance.




Aucun commentaire:

Enregistrer un commentaire