Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82041

How to pass a value from JS to a HTML hidden input field

$
0
0
I want to take the value that assigned to the variable 'sData' and place it in a HTML hidden input field. The javascript below resides in the header section. I'm having problems getting the value to be properly placed in a hidden input field on my HTML page to be passed to my server for querying and processing.

<script>
// Individual cell data
$(document).ready(function() {
oTable = $('#example').dataTable();

oTable.$('tr').click( function () {
var sData = oTable.fnGetData( this )[0];
// alert( 'The cell clicked on had the value of '+sData );

} );
} );

</script>

... I want the sData value to be placed in an HTML input field in the body of the page similar to this:

input type="hidden" id="lookup" name="lookup" value="sData"

How would I achieve this, and where should any code additions be placed?

Thanks for your help!

Viewing all articles
Browse latest Browse all 82041

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>