Assign variable the value of a column in a selected row
Assign variable the value of a column in a selected row
Use case:
1. User selects a row in the table.
2. A variable (say, acctnum) is assigned the value of the data in first column in this row.
3. Submit button is clicked on the form and variable is passed to the server for processing.
What would I do to have DataTables assign the value to the variable before the Submit button is pressed. How would the code look?
Thanks in advance for your help. Still somewhat new to coding!
1. User selects a row in the table.
2. A variable (say, acctnum) is assigned the value of the data in first column in this row.
3. Submit button is clicked on the form and variable is passed to the server for processing.
What would I do to have DataTables assign the value to the variable before the Submit button is pressed. How would the code look?
Thanks in advance for your help. Still somewhat new to coding!
This discussion has been closed.
Replies
[code]
table.$('tr').click( function () {
$('input...').val( table.fnGetData( this )[0] );
} );
[/code]
Note the use of fnGetData - passing in the 'TR' that was clicked on and the first index value from the data array front he object.
There are a lot of variations on this that are possible, but this is the basic idea :-).
Allan