JSFiddle - React, Tailwind, and code Playground

by Tushar Gupta

HTML

<form id="form1" runat="server">
    <input type="hidden" id="spn_Price" name="sum" value="">
    <br>
    <input id="rdo_1" type="radio" value="159" name="price" onclick="DisplayPrice(this.value);">159
    <br>
    <input id="rdo_2" type="radio" value="259" name="price" onclick="DisplayPrice(this.value);">259
    <br>
    <br>100
    <input type="checkbox" value="100" />
    <br>200
    <input type="checkbox" value="200" />
    <br>300
    <input type="checkbox" value="300" />
    <br/>
    <input type="button" id="b1" value="get total" />
    <input type="text" name="totalSum" id="totalSum" value="" size="2" readonly="readonly">
</form>

JavaScript

$('input[type="checkbox"],input[type=radio]').change(function () {
    var total = 0;
    $("input[type=radio]:checked").each(function () {
        total += parseFloat($(this).val());
    });
    $('input[type="checkbox"]:checked').each(function () {
         total += parseFloat($(this).val());
    });
    $("#totalSum").val(total);
});