0

So basically I have a 5 checkboxes where if the user selects any of the two boxes the rest will be disabled so that they can't pick anymore but enable those boxes if any of the two boxes are deselected.

This will be inside a form.

Thanks!

So I tried one of the method below with the following code:

<input type="checkbox" name="checkAll" id="checkAll">??
<input type="checkbox" name="checkOUT" id="checkOUT">AA
<input type="checkbox" name="book" class="book" value="book1">book1
<input type="checkbox" name="book" class="book" value="book2">book2
<input type="checkbox" name="book" class="book" value="book3">book3
<input type="checkbox" name="book" class="book" value="book4">book4
<input type="checkbox" name="book" class="book" value="book5">book5</table>

<script>
$(function () {
$("#checkAll" && "#checkOUT").click(function () {
    if ($("#checkAll" && "#checkOUT").is(':checked')) {
        $(".book").prop("disabled", true);
    } else {
        $(".book").prop("disabled", false);
    }
});
});
</script>

I can't seem to get it so when both checkboxes are selected then disable.

1 Answers1

0

In the "CheckedChanged" event of an active CheckBox, enable the other CheckBox.

Private Sub chkbx_one_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkbx_one.CheckedChanged
  If DirectCast(sender, CheckBox).Checked = True Then
    chkbx_two.Enabled = True
  End If
End Sub
gilu
  • 197
  • 2
  • 9