How do I get a value from a datatable
How do I get a value from a datatable
autkiller97
Posts: 1Questions: 1Answers: 0
I have tried and googled just to find no solution.
I want to get a value a selected row of my datatable (the ID) but i dont how to do so.
The value shoud be given to a textbox
Here is my Code:
var oTable = $('#dataTable').dataTable();
$.ajax({
url: 'process.php?method=fetchdata',
dataType: 'json',
success: function(s){
console.log(s);
oTable.fnClearTable();
for(var i = 0; i < s.length; i++) {
oTable.fnAddData([
s[i][0],
s[i][1],
s[i][2],
s[i][3],
s[i][4],
]);
}
},
error: function(e){
console.log(e.responseText);
}
});
$('#dataTable tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
} );
Hopefully someone can help me!
This discussion has been closed.