how to calculate the total in the Form inputs with multiple pages

how to calculate the total in the Form inputs with multiple pages

surfingsurfing 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

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Use Data tables API method $() to run a jQuery selector against all types in the table.

    table.$(':input').each(...)
    

    (That was hard to type on a phone!)

    Allan

  • surfingsurfing Posts: 10Questions: 3Answers: 0

    I used .each but it only work for current page

  • surfingsurfing Posts: 10Questions: 3Answers: 0

    table
    .column( 0 )
    .data()
    .each( function ( value, index ) {
    alert( 'Data in index: '+index+' is: '+value );
    } );

    thank you,Allan. I got the idea

Sign In or Register to comment.