how to calculate the total in the Form inputs with multiple pages
how to calculate the total in the Form inputs with multiple pages
surfing
Posts: 10Questions: 3Answers: 0
Link to test case: sample https://datatables.net/examples/api/form.html
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
So I want to calculate total for one of the column for all these pages.
Usually if I use a jquery code like below for total, but it can only get total for current page
$("#mytable :input").each(function(index, elem){
temporary01 = $(elem).val();
total += temporary01;
$(elem).val(temporary01);
});
How do I get total for all pages? Anyone had similar issue?
This question has an accepted answers - jump to answer
Answers
Use Data tables API method
$()
to run a jQuery selector against all types in the table.(That was hard to type on a phone!)
Allan
I used .each but it only work for current page
table
.column( 0 )
.data()
.each( function ( value, index ) {
alert( 'Data in index: '+index+' is: '+value );
} );
thank you,Allan. I got the idea