title: jQuery looping checkboxes
body: <p>I have a page that contains many checkboxes. There are a set of checkboxes that have an ID prefixed with pbfam_ and it is only these I am interested in.</p>
  
  <p>When a user clicks on one of these, I need to get a list of the IDs from that subset of only the ones that are checked, and I need it to be a comma delimited string of the IDs.</p>
  
  <p>The HTML looks like this:</p>
  
  <pre><code>&lt;input type="checkbox" id="pdfam_711131" /&gt;
  &lt;label for="pdfam_711131" class="VIEWBOX"&gt;Temporary Staff&lt;/label&gt;
  &lt;br /&gt;
  &lt;input type="checkbox" id="pdfam_711341" /&gt;
  &lt;label for="pdfam_711341" class="VIEWBOX"&gt;Other Contractors&lt;/label&gt;
  &lt;br /&gt;
  </code></pre>
  
  <p>There are about 40 of these checkboxes. What I'm looking for is a string like:</p>
  
  <p><code>"pdfam_711131, pdfam_711341"</code></p>
  
  <p>I've tried various things and nothing has worked. I'm quite new to jQuery. This gives me a list of checked ones and returns the checked value in an alert and I was trying to mess around with this but I have got nowhere.</p>
  
  <pre><code>$('input:checkbox[id^="pdfam_"]:checked').each(function(){alert($(this).attr("id")););
  </code></pre>