This is a MVC 3 application that uses the razor view engine. I have the following line of code in a view that displays 2 checkboxes. When one is checked the other checkbox should uncheck. I have searched around and between my lack of exp with javascript and the lack of threads found on google related to this i am at a lost for even a code snip of javascript to use for a worthwhile starting point. Any ideas?? This below is what I have coded up on my own but am more stuck than anything with this.
        $("#isStaffCheckBox").change(
              function (e) {
                  var checked = $(this).attr('checked');
                  if(checked)
                  {
    <li>Staff Member: @Html.CheckBoxFor(Function(f) f.isStaff, New With {.id = "isStaffCheckBox"}) Board Member: @Html.CheckBoxFor(Function(f) f.boardMember, New With {.id = "isBoardCheckBox"})</li>
Any help is greatly appreciated..
If there is some reason for this to be a checkbox instead of a radio button then the following code should do it.
    $("#isStaffCheckBox").change(
          function (e) {
              $("#isBoardCheckBox").prop('checked',!this.checked);
          }
    });
                        Change the property "("#isBoardCheckBox").prop" to "("#isBoardCheckBox").attr".
Works fine!
  $("#isStaffCheckBox").change(
  function (e) {
      $("#isBoardCheckBox").attr("checked", !this.checked);
  })
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With