title: Adding up check boxes, adding the price into a database
body: <p>I'm trying to add tick boxes and when the boxes are ticked a value adds up (a variable) that variable is then added into the database along with each checkbox once the form is submitted, I've been trying to modifiy this code but cant figure out how to not use the parseInt() function and output a single variable that I can then add into the database/Email reply to the customer. I'm really stuck and would appreciate some help. </p>
  
  <p>(the options are suppose to actually be (deodoriser,carpet,carpetrepair,furniture,tabs,urine but im using demo options for now below in the insert staement they are the correct names)
  This is my HTML:</p>
  
  <pre><code>&lt;p&gt;&lt;input type="checkbox" name="extras[]" value="option1" rel="11"&gt;furniture&lt;/p&gt;
  &lt;p&gt;&lt;input type="checkbox" name="extras[]"" value="option2" rel="12"&gt;tabs&lt;/p&gt;
  &lt;p&gt;&lt;input type="checkbox" name="extras[]" value="option3" rel="13"&gt;urine&lt;/p&gt;
  &lt;p&gt;&lt;input type="checkbox" name="extras[]" value="option4" rel="30"&gt;couch&lt;/p&gt;
  &lt;p&gt;&lt;input type="checkbox" name="extras[]" value="option5" rel="20"&gt;steam&lt;/p&gt;
  &lt;span id="output"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>This is my javascript function</p>
  
  <pre><code>$(document).ready(function() {
      function recalculate() {
          var sum = 0;
  
          $("input[type=checkbox]:checked").each(function() {
              sum += parseInt($(this).attr("rel"));
          });
  
          $("#output").html(sum);
      }
  
      $("input[type=checkbox]").change(function() {
          recalculate();
      });
  });
  </code></pre>
  
  <p>This is my email reply/datbase inserting at the moment</p>
  
  <pre><code>$idextra=$_POST['extras'];
  $arr_num=count($idextra);
  $i=0;
  while ($i &lt; $arr_num)
  {
  
      $q="INSERT INTO bs_reservations (dateCreated, name, email, phone, comments,status,eventID, qty,dropoff,deodoriser,carpet,carpetrepair,furniture,tabs,urine) VALUES (NOW(),'".$name."','".$email."','".$phone."','".$comments."','2','".$eventID."','".$qty."','".$dropoff."','{$idextra[1]}','{$idextra[2]}','{$idextra[3]}','{$idextra[4]}','{$idextra[5]}','{$idextra[6]}')";
  
      $res=mysql_query($qu) or die('ERROR INSERTING: '.mysql_error());
      $i++;
  }
  </code></pre>
  
  <p>Thanks heaps for any advice/help in coding this. I know its a big question but I feel it will help a lot of people in the future.</p>