title: Select all checkbox with jQuery form POST for multiple checkboxes
body: <p>For a project I want to implement a nice filtering mechanism with multiple checkboxes. I get the checkboxes to work correctly as well as a jQuery function to automatically POST the form when checking a checkbox.</p>
  
  <p>Now I want to add a "select all" checkbox above the checkboxes, but I cannot seem to find the correct way. I have tried a dozen solutions for (somewhat) similar questions but I cannot get it to work correctly and consistent.</p>
  
  <p>The HTML part is something like this:</p>
  
  <pre><code>&lt;form action="&lt;?php $_SERVER['PHP_SELF']?&gt;" method="post"&gt;
      &lt;input type="checkbox" /&gt; Select All colors&lt;br/&gt;
  
      &lt;label&gt; &lt;input type="checkbox" name="color[]" value="yellow"&gt; Yellow&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="color[]" value="blue"&gt; Blue&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="color[]" value="red"&gt; Red&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="color[]" value="green"&gt; Green&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;
  
      &lt;input type="checkbox" /&gt; Select All brands&lt;br/&gt;
  
      &lt;label&gt; &lt;input type="checkbox" name="brand[]" value="Nike"&gt; Nike&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="brand[]" value="Adidas"&gt; Adidas&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="brand[]" value="SomeBrand"&gt; SomeBrand&lt;/label&gt;&lt;br/&gt;
      &lt;label&gt; &lt;input type="checkbox" name="brand[]" value="SomeOtherBrand"&gt; SomeOtherBrand&lt;/label&gt;&lt;br/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The jQuery part I use to post the form on each click on the checkbox (is not sufficient):</p>
  
  <pre><code>$('input:checkbox:').live('click',function() {
      $(this).closest('form').submit();
  });
  </code></pre>
  
  <p>My question now is what do I need for the jQuery part to make sure this works correctly? 
  I want to be able to click the label to deselect all from that group and select only that one checkbox. It also needs to POST the form for the array values. And lastly if all checkboxes are checked manually the "select all" one has to be checked as well.</p>
  
  <p>Hopefully someone can help me out as I am stuck with this for a long time...</p>