return the row ID for each item checked

return the row ID for each item checked

maryPomaryPo Posts: 11Questions: 4Answers: 0
edited March 2015 in Free community support

hello! Each row of my table and contains a checkbox object. I need to get the value of each checkbox and object ID of each effluent. I tried to do

$("input", seriesTasksTable.fnGetNodes()).each(function(index){
                console.log(seriesTasksTable.fnGetData(index)["id"]);
                console.log(this.value);
});

, but the values are mixed, the checkbox and id object returned from different rows. This code is correct?

Please tell me how to fix it. Any ideas.

Answers

  • maryPomaryPo Posts: 11Questions: 4Answers: 0

    Is it possible to get the position of the checkbox? And then get an object of this position?
    but I do not know how to get the position of the node on chechkboks. My solution does not work.

    $('input:checked', seriesTasksTable.fnGetNodes()).each(function(index){
                    var aPos = seriesTasksTable.fnGetPosition( this );
                    console.log(seriesTasksTable.fnGetData(aPos));
                    console.log( this.value);
                });
    
  • maryPomaryPo Posts: 11Questions: 4Answers: 0

    I don't understand why the fnGetData(index) returns the value of a single line, and the this.value from the other line, although they are in the same cycle?

    $("input", seriesTasksTable.fnGetNodes()).each(function(index){
                    console.log(seriesTasksTable.fnGetData(index)["id"]);
                    console.log(this.value);
    });
    
  • maryPomaryPo Posts: 11Questions: 4Answers: 0

    question resolved

    $('input:checked', seriesTasksTable.fnGetNodes()).each(function(index){
         console.log( this.value);
         console.log(seriesTasksTable.fnGetData($(this).closest('tr')[0])["id"]);
    });
    
This discussion has been closed.