1

I have a HTML table that is populated directly from a bit of PHP that pulls data in from a mySQL table.

I have the table set up so each row can be clicked to load a modal containing a form to allow data to be updated and submitted back to the database using a mysql update query.

The problem I have is passing the HTML table row ID back into my PHP select to return the 1 table row that has been clicked.

As I am using a row click to launch the modal, I don't want to use a form submit option to trigger to POST a variable?

Any ideas how I could do this?

Thanks

  • Possible duplicate of [Passing data to a bootstrap modal](http://stackoverflow.com/questions/10626885/passing-data-to-a-bootstrap-modal) – Rahul Singh Apr 20 '16 at 09:57

1 Answers1

0

You can write the row ID in a html attribute and use JS to read it from there.

Sample html:

<tr row_id="1234"></tr>

Sample JS (jQuery):

jQuery("tr").click(function(e) {
  var row_id = jQuery(e.currentTarget).attr("row_id");
});
TehSphinX
  • 6,536
  • 1
  • 24
  • 34