This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

Calculate Total Value Of Checkboxes Using Jquery

Calculate Total Value Of Checkboxes Using Jquery Checkbox,Jquery Calculate Total Value Of Checkboxes Using Jquery

If one checkbox is selected, it will add the values of checkboxes automatically. If you will click unchecked, the total will be updated automatically.
JQUERY

 $(document).ready(function() { $("input[type=checkbox]").change(function(){ recalculate(); }); function recalculate(){ var sum = 0; $("input[type=checkbox]:checked").each(function(){ sum += parseInt($(this).attr("rel")); }); // alert(sum); $("#output").html(sum); } });
HTML
<div> <p><input type="checkbox">Book</p> <p><input type="checkbox">Bag</p> <p><input type="checkbox">Notebook</p> </div> <span></span> 

Ref: http://stackoverflow.com/questions/5066537/calculate-total-value-checkboxes-jquery

0 Response to "Calculate Total Value Of Checkboxes Using Jquery"

Posting Komentar

Contact

Nama

Email *

Pesan *