title: jQuery sum checkbox values
body: <p>I'd need to calculate sum of all checkboxes and update total based on selection here is html:</p>
  
  <pre><code>&lt;input type="checkbox" id="basic_single" name="basic_single" value="400"&gt;
  &lt;input type="checkbox" id="basic_double" name="basic_double" value="680"&gt;
  .
  .
  .
  &lt;input type="text" name="total" value="" size="30" id="total"&gt;
  </code></pre>
  
  <p>here is the script</p>
  
  <pre><code>   $('input:checkbox').change(function ()
       {
        var total = 0;
        var basic_single = parseInt($('#basic_single:checked').val());
        var basic_double = parseInt($('#basic_double:checked').val());
  
        var total = basic_single + basic_double;
  
        $("#total").val(total);
  
      });
  </code></pre>
  
  <p>if both are checked it works fine, but just one checked returns NaN,
  there will be more checkboxes than just these two</p>