Answers for "jquery table row calculation"

0

jquery table row calculation

$(function () {
    var tbl = $('#tbl_a');
    tbl.find('tr').each(function () {
        $(this).find('input[type=text]').bind("keyup", function () {
            calculateSum();
        });
    });

    function calculateSum() {
        var tbl = $('#tbl_a');
        tbl.find('tr').each(function () {
            var sum = 0;
            $(this).find('input[type=text]').not('.total').each(function () {
                if (!isNaN(this.value) && this.value.length != 0) {
                    sum += parseFloat(this.value);
                }
            });

            $(this).find('.total').val(sum.toFixed(2));
        });
    }
});
Posted by: Guest on June-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language