title: Checkbox Enable/Disable with jQuery
body: <p>I want to have a jquery function that will be activated when any checkbox is clicked and based on the value field of the checkbox that is clicked it will disable or enable other checkboxes.</p>
  
  <p>So far I have:</p>
  
  <pre><code>$(function () {
      $('input [type="checkbox"]').click(function () {
  
      });
  });
  </code></pre>
  
  <p>Okay, so I've made some progress.. but it's still not working.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function () {
      $(':checkbox').click(function () {
  
          $value = $(this).attr('value');
  
          if ($(this).is(':checked'))
          {
              switch ($value)
              {
                  case "BLIPA":
                      $(':checkbox[value*="B"]').attr('disabled', true);
              }
          }
          else
          {
              $(':checkbox').each(function()
              {
  
              }
          }
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>Have I made any mistakes?</p>
  
  <p>Edit:</p>
  
  <p>Okay so I have solve it. Here is the solution:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function () {
      $("input[type='checkbox']").click(function () {
  
          var value = $(this).attr('value');
  
          if ($(this).is(':checked')) {
  
              var modules = FindModuleRules(value);
  
              $(':checkbox[value*="' + modules[0] + '"]').attr('disabled', true);
              $(':checkbox[value*="' + modules[1] + '"]').attr('disabled', true);
              $(':checkbox[value*="' + modules[2] + '"]').attr('disabled', true);
              $(':checkbox[value~="' + value + '"]').attr('disabled', false);
  
          }
          else {
              var modules = FindModuleRules(value);
  
              $(':checkbox[value*="' + modules[0] + '"]').attr('disabled', false);
              $(':checkbox[value*="' + modules[1] + '"]').attr('disabled', false);
              $(':checkbox[value*="' + modules[2] + '"]').attr('disabled', false);
          }
      });
  
      function FindModuleRules(string) {
  
          var modules = new Array();
  
          var bRegex = /B/;
          var lRegex = /L/;
          var aRegex = /A/;
  
          if (string.search(bRegex) != -1)
              modules[0] = "B";
          else
              modules[0] = "X";
          if (string.search(lRegex) != -1)
              modules[1] = "L";
          else
              modules[1] = "X";
          if (string.search(aRegex) != -1)
              modules[2] = "A";
          else
              modules[2] = "X";
  
          return modules;
      }
  
  });
  </code></pre>
  
  <p></p>