title: In jQuery How do turn a subset of checkboxes on and off based on another checkbox
body: <p>I have a list of divisions and subdivisions that I show with checkboxes, dynamically created through a database with the end result somewhat like this:</p>
  
  <pre>
  &lt;input name="divisions[]" type="checkbox" value "division1"/&gt; Division One
      &lt;input name="departments[]" type="checkbox" value "department1"/&gt; Department One
      &lt;input name="departments[]" type="checkbox" value "department2"/&gt; Department Two
  
  &lt;input name="divisions[]" type="checkbox" value "division2"/&gt; Division Two
      &lt;input name="departments[]" type="checkbox" value "department3"/&gt; Department Three
      &lt;input name="departments[]" type="checkbox" value "department4"/&gt; Department Four
  </pre>
  
  <p>I need to write the jQuery code such when the user clicks on the a division all of its departments and only its departments are equally clicked on or off.</p>
  
  <p>I was thinking of attaching a clicked event function to all divisions that turned on or off all the immediate departments, though I don't know the syntax:
  conceptually I was thinking:</p>
  
  <pre><code>jQuery(document).ready(function() {
      $(all_elements_with_the_name_divisions).click(function() {
          $(all_immediately_following_elements_with_the_name_departments).attr('checked',this.checked);
      });
  })
  </code></pre>
  
  <p>thanks</p>