showing results for - "jquery table row calculation"
Chiara
17 Jun 2017
1$(function () {
2    var tbl = $('#tbl_a');
3    tbl.find('tr').each(function () {
4        $(this).find('input[type=text]').bind("keyup", function () {
5            calculateSum();
6        });
7    });
8
9    function calculateSum() {
10        var tbl = $('#tbl_a');
11        tbl.find('tr').each(function () {
12            var sum = 0;
13            $(this).find('input[type=text]').not('.total').each(function () {
14                if (!isNaN(this.value) && this.value.length != 0) {
15                    sum += parseFloat(this.value);
16                }
17            });
18
19            $(this).find('.total').val(sum.toFixed(2));
20        });
21    }
22});