title: Add and subtract values with jQuery
body: <p>Need Help with following piece of jQuery code;</p>
  
  <p>What I'm trying to do is;</p>
  
  <ol>
  <li>add Amount into Total</li>
  <li>when amount added Checkbox value get double</li>
  <li>If checkbox state change, checkbox Updated value minus or add into Total accordingly</li>
  <li>if Amount minus from Total, checkbox value change back to original </li>
  <li>If checkbox state change, checkbox Updated value minus or add into Total accordingly</li>
  </ol>
  
  <p>Following is the piece of jQuery Code</p>
  
  <pre><code>$('#Addcar').on('click', function() {
  if($(this).html()=='Add') {
      $(this).html('Remove');
      var tot = parseFloat($('#TotalAmount').val()) + parseFloat($('#QuoteAmount').val());
      var totcan = parseFloat($('#Cancelation').val()) + 2;
      $('#TotalPrice').val(tot);
      $('#Cancelation').val(totcan);
  } else {
      $(this).html('Add');
      var tot = parseFloat($('#TotalPrice').val()) - parseFloat($('#QuoteAmount').val());
      var totcan = parseFloat($('#Cancelation').val()) - 2;
      $('#TotalPrice').val(tot);
      $('#Cancelation').val(totcan);
  }
  });
  
  $('#Cancelation').change(function(){
  if($(this).is(':checked')){
      total = parseFloat($('#TotalPrice').val()) + Number($(this).val());
  } else {
      total = parseFloat($('#TotalPrice').val()) - Number($(this).val());
  }
  $('#TotalPrice').val(total);
  });
  </code></pre>
  
  <p>Here is the fiddle which explains better;</p>
  
  <p><strong>Updated Fiddle:</strong><br>
  <a href="http://jsfiddle.net/55n8acus/7/" rel="nofollow">http://jsfiddle.net/55n8acus/7/</a></p>
  
  <p>If QuoteAmount value added and checkbox value remove from Total and then remove QuoteAmount value , the result value will be wrong, it should be 52 not 48, the reason checkbox won't update and it still remove 4 from Total instead it should remove 2.</p>
  
  <p>Thanks for all the help</p>
  
  <p>Regards.</p>