Welcome Guest, Not a member yet? Register   Sign In
how to sum all td values ?
#2

That's because you are assigning individual value to the field, not sum. Haven't tested it, but something like this should work:

Code:
<script>
function updateTotal()
{
    var total = 0;
    $('#dynamic-table tr').each(function() {
        if (!this.rowIndex) return; // skip first row
        var customerId = this.cells[4].innerHTML;
        total += customerId;
    }
    $("#grand_total").val(total);
});

Out of curiosity, why are you not doing that on PHP side?
Reply


Messages In This Thread
how to sum all td values ? - by kvanaraj - 10-11-2018, 01:33 AM
RE: how to sum all td values ? - by Pertti - 10-11-2018, 02:15 AM
RE: how to sum all td values ? - by php_rocs - 10-11-2018, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB