title: selecting checkboxes based on value?
body: <p>So I have the code below. I need to add some html buttons for certain companies to be selected when the link is clicked. Sorta like a select all, select none. But it will be select corporate companies, select franchise companies, etc. All companies are based on ID. How can I use the value in my input type to be checked based on these links?
  Example: </p>
  
  <p>Link: Select Corporate. (ID's that should be checked after clicking the link: 1, 14, 17, 47)</p>
  
  <pre><code>  &lt;p&gt;
  &lt;input type="checkbox" name="sites[]" id="site-1" value="1" checked="checked"/&gt;
  &lt;label for="site-1" style="float: none; display: inline; "&gt;Company 1&lt;/label&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="checkbox" name="sites[]" id="site-14" value="14" checked="checked"/&gt;
  &lt;label for="site-14" style="float: none; display: inline; "&gt;Company 14&lt;/label&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="checkbox" name="sites[]" id="site-17" value="17" checked="checked"/&gt;
  &lt;label for="site-17" style="float: none; display: inline; "&gt;Company 17&lt;/label&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="checkbox" name="sites[]" id="site-47" value="47" checked="checked"/&gt;
  &lt;label for="site-47" style="float: none; display: inline; "&gt;Company 47&lt;/label&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>This is the code I currently have for select all, select none, and what actually generates all my companies that can be checked:</p>
  
  <pre><code>&lt;p&gt;&lt;label&gt;Show on Sites:&lt;br&gt;&lt;a href="" onclick="$('sites').select('input[type=checkbox]').each(function(e){if(!e.checked)e.click();}); return false;"&gt;Select All&lt;/a&gt; | &lt;a href="" onclick="$('sites').select('input[type=checkbox]').each(function(e){if(e.checked)e.click();}); return false;"&gt;Select None&lt;/a&gt;&lt;/label&gt;&lt;/p&gt;
              &lt;div style="float: left;" id="sites"&gt;
                  -- Select brand first --
                  &lt;?
                  if($promotion-&gt;id) {
                      $sites = DBObject::getObjects('Company', "company_id IN (SELECT company_id FROM company_promotions WHERE promotion_id = '{$promotion-&gt;id}')");
                      foreach($sites AS $site) {
                          ?&gt;
                      &lt;input type="hidden" value="&lt;?= $site-&gt;id ?&gt;"&gt;
                          &lt;?
                      }
                  }
                  ?&gt;
              &lt;/div&gt;
  </code></pre>