Return to Snippet

Revision: 48808
at July 9, 2011 12:47 by sdxxx


Updated Code
<script> $("input[type=radio]").click(function() { var total = 0; $("input[type=radio]:checked").each(function() { total += parseFloat($(this).val()); }); $(".totalSum").val(total); }); </script> <html> <body> <input type="radio" value="15"/> <input type="radio" value="20"/> <input type="radio" value="30"/> <input class="totalSum" type="text"/> </body> </html>

Revision: 48807
at July 9, 2011 12:46 by sdxxx


Updated Code
<script> $("input[type=radio]").click(function() { var total = 0; $("input[type=radio]:checked").each(function() { total += parseFloat($(this).val()); }); $(".totalSum").val(total); }); </script> <html> <body> <input type="radio" value="15"/> <input type="radio" value="20"/> <input type="radio" value="30"/> <input class="totalSum" type="radio"/> </body> </html>

Revision: 48806
at July 9, 2011 12:43 by sdxxx


Initial Code
$("input[type=radio]").click(function() { var total = 0; $("input[type=radio]:checked").each(function() { total += parseFloat($(this).val()); }); $("#totalSum").val(total); });

Initial URL
http://stackoverflow.com/questions/1324703/how-might-i-calculate-the-sum-of-radio-button-values-using-jquery

Initial Description
 

Initial Title
Calculate the sum of radio button values using jQuery

Initial Tags
 

Initial Language
jQuery