javascript - Tracking Multi-page Forms in Datatables -


i have order form that's several pages long, users can input quantities of items. i'm trying keep running total of order total.

https://jsfiddle.net/kodemonki/9vj98u9m/3/

here's bulk of code i've been working with. can see of i've tried.

 function recalculate(){     var qtyarray = new array();     var costarray = new array();     var total_cost = 0;      // iterate on checkboxes in table     // $('input[type="number"].part_qty').each(function(){     //  // if checkbox doesn't exist in dom     //  if(!$.contains(document, this)){     //      // create hidden element      //      $(form).append(     //          $('<input>')     //              .attr('type', 'hidden')     //              .attr('name', this.name)     //              .val(this.value)     //              .attr('class','part_qty')     //      );     //  }      // });      //$('input[type=number].part_qty').each(function(){     $('input[type=number]').each(function(){         qtyarray.push(number($(this).val()));         //console.log(this);     });     $('.part_cost').each(function(){         costarray.push(number($(this).html().replace(/[^0-9\.]+/g,"")));      });      for(var = 0;i < qtyarray.length; i++){         // console.log(qtyarray[i] + isnan(qtyarray[i]));         // console.log(costarray[i] + isnan(costarray[i]));         total_cost = total_cost + (qtyarray[i] * costarray[i]);         //console.log(total_cost);     }         total_cost = math.round(total_cost*100)/100;      var table = $('#partslist').datatable();     var data = table.$('input').serialize();     // console.log(data);         //console.log(qtyarray);     //console.log(costarray);     //$(#order_total).html('32532');     $("#order_total").html('$'+total_cost); } 

not sure why pagination or total isn't showing in fiddle. looks fine on dev site.

however, can't total keep track across pages. i've looked @ several solutions , can't seem it. form submission added removed data in, same solution doesn't seem work totals.

thank you.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -