DaithiOK DaithiOK - 3 months ago 7x
Javascript Question

How to pass the value from a dynamically created table into a new database query using JQuery?

So far I've created a table from a database query using the input from a dropdown menu. Now I want the user to be able to click on a cell in that table and using the the value of that cell query the database again for further information. Here's what I have:

echo "
<td><a href='#'><div value=".$value['First_Name'].">".$value['First_Name']."</div></a></td>

This continues on for the rest of the information but thats the code for my initial table. The user should then click on First_Name for further information provided by an AJAX request. My jQuery so far looks like this...I haven't even been able to start the AJAX as I can't pass in the value of the table cell.

$('#tables').on('click','td', function(){
var module= $(this).val();

Once I figure out how to pass this value then I can move ahead with the database query but this is holding me back. Do I even need to do this if Im using JQuery AJAX? Any help is appreciated.


if you want get the text inside the element tag. Please use .text() not .val() example:

var module= $(this).text();

I hope this usefull :)