Search code examples
phphtml-tablerow

How to click on HTML table row and send row's data to PHP (as POST)?


I need to make a table with clickable rows (for this I found some Javascript solutions). When I click one row, a form will be filled with data from the clicked row.

But I don't know how to send the data from HTML table to PHP, when I click on that row. Data must be sent as POST, as I mentioned in title.

I have no idea how to start, so I cannot show you nothing. Using multiple forms inside one table is not allowed, <a> tag around <td> is not allowed either, so I'm stuck. From what I searched on web, the solution would be AJAX, but I'm not familiarized with it, never used AJAX, so if possible, a non-AJAX solution would be much appreciated. If not, please show me a functional example.


Solution

  • After filling your form (name="myform" and method="post") from JavaScript, simply call:

    document.myform.submit();
    

    This should do the work