calculated columns - Dynamic jQuery add up totals and shipping and tax for invoice -
i having trouble adding calculations items add subtotal adding shipping input value , tax, e.g.:
item + item = subtotal subtotal + shipping = total total + 10% = grandtotal
i calling class add items up:
$(document).ready(function() { // add new row on invoice var cloned = $('#invoice_tables .clone').clone(); $(".add-row").click(function (e) { e.preventdefault(); cloned.clone().appendto('#invoice_tables'); }); //calculatesum(); $('#invoice_tables').on('change keyup keydown paste', '.txt', function() { // updatetotals(this); calculatesum(); }); //calculatesum(); $('#invoice_table').on('change keyup keydown paste', '.txt', function() { // updatetotals(this); calculatesum(); }); // remove row $('#invoice_tables').on('click', ".delete-row", function(e){ e.preventdefault(); $(this).closest('.clone').remove(); calculatesum(); }); //iterate through each textboxes , add keyup //handler trigger sum event $(".txt").each(function() { $(this).keyup(function() { calculatesum(); }); }); }); function calculatesum() { var sum = 0; //iterate through each textboxes , add values $(".txt").each(function() { //add if value number if (!isnan(this.value) && this.value.length != 0) { sum += parsefloat(this.value); } }); //.tofixed() method roundoff final sum 2 decimal places $("#sum").html(sum.tofixed(2)); //$("#sum input").val(sum.tofixed(2)); }
the #invoice_tables
coming database , #invoice_table
added add new rows.
i have items description
, quantity
, cost
. when these added work using #sum div
. here need have shipping input value , calculate tax grand total.
i grateful ideas have tried adding new #sum2
not adding up.
Comments
Post a Comment