Skip to content Skip to sidebar Skip to footer

How Might I Calculate The Sum Of Radio Button Values Using Jquery?

I am trying to create a form with many groups containing many radio buttons. When the user selects a button, I would like to calculate the sum of each selected radio button value a

Solution 1:

Plugin schmugin. Get rid of your onclick and try this:

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

    $("#totalSum").val(total);
});

Post a Comment for "How Might I Calculate The Sum Of Radio Button Values Using Jquery?"