How can I get a cell value when I select a table row?
How can I get a cell value when I select a table row?
gbeard
Posts: 2Questions: 1Answers: 0
I have a table setup, I need to get the value of the first cell and store it into a var. I can click on the cell and it works, I need to be able to click on the row and get the first cell value.
$(document).ready(function() {
var table = $('#tmcustlist').DataTable();
$('#tmcustlist tbody').on( 'click', 'td', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
var custid = (table.cell(this).data()); // This is where I need the data stored.
var link;
link = 'marketreg.php?task=tmMarketReg&id=' + custid;
window.location = link;
} );
} );
This discussion has been closed.
Answers
so to store in a var would simply be:
This is how I fixed my issue, I took the result from my label row and did a string manipulation to get the first characters before the ',':