Hello, I guess this is easy, I am working with PHP and MySQL, and I build a table with result of a sql query, the table strutcture is: <table> <tr><td>ID</td><td>Name</td><td>E-mail</td><td> <?php include 'config.php'; include 'opendb.php'; $query= 'select * from customers.contact'; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ echo "<tr><td>", $row['cid'],"</td>". "<td>", $row['cname'],"</td>". "<td>", $row['csubject'], "</td></tr>"; } include 'closedb.php'; ?> Code (markup): And you now, return a table with 3 fields and the database information, now, I want to do, for example, click over the table cell ID number 35, and when I do click, javascript return the value 35, this is for update and delete scripts, but I don't know how to get the value into a that cell or another cells, ¿how do I can get it? Thank you for the help
You can reach the TR element from the TD element by using this.parentNode (this = td you clicked on it), and then go to the first cell by using .childNodes[0].innerText I hope it is enough explained. if you need further help - respond.
You've got the ID when you generate the page, so you can dynamically create the JS too with the required id. There shouldn't be any need for DOM traversal