Datatable sorting leading to incorrect data on post
Datatable sorting leading to incorrect data on post
I am trying to implement a function where user selects a checkbox within a row in a datatable. The checkbox is generated via PHP where $i = 0....n
echo '<td > <input type="checkbox" name="selected[]" id="col_selected" class="selectchk" value="'.$i.'"> </td>';
Let's say I have table like this:
row 0 checkbox 1 (value = 0) otherdata0
row 1 checkbox 2 (value = 1) otherdata1
When checkbox 1 is selected and form posted I get:
[selected] => Array ( [0] => 0 ) otherdata[0] = otherdata0
[selected] => Array ( [0] => 1 ) otherdata[1] = otherdata1
However, if the rows are sorted by the user so that I have the table displayed as follows:
row 1 checkbox 2 (value = 1)
row 0 checkbox 1 (value = 0)
I get the following when checkbox 1 is selected:
[selected] => Array ( [0] => 1) otherdata[1] = otherdata0
It seems like the data from the rest of the table does not sync with the checkbox being sorted.
Any ideas?