Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- $("input").each(function () {
- $(this).keyup(function () {
- newSum.call(this);
- });
- });
- });
- function newSum() {
- var sum = 0;
- var thisRow = $(this).closest('tr');
- var total = 0;
- //iterate through each input and add to sum
- $(thisRow).find("td:not(.total) input").each(function () {
- sum += parseInt(this.value);
- });
- //change value of total
- $(thisRow).find(".total").html(sum);
- // the grand total
- $('.total').each(function () {
- total += parseInt($(this).html());
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement