Issue
I'm stuck at a crossroads trying to figure out how to address a problem I need to solve.
I have a table (HTML) that looks like this:
+----+------------+----------+---------------------+----------+
| id | filename | uploader | upload_time | DELETE? |
+----+------------+----------+---------------------+----------+
| 1 | backup.txt | user1 | 2014-06-10 13:39:41 | [BTN] |
| 2 | test.txt | user2 | 2014-06-11 16:57:01 | [BTN] |
+----+------------+----------+---------------------+----------+
The problem comes into play with the last column. When the user clicks a button, I need to determine the row, and send that data to a servlet.
I know how to handle everything in the servlet and beyond, but I don't know how I can send data to the servlet so it knows which button the user clicks on.
Can anyone suggest a good method to go about this?
Solution
Create a form for each button, with hidden input that contain the id :
Button 1 :
<form action="/yourServlet" method="POST">
<input name="id" type="hidden" value="1">
<input type="submit" value="delete 1">
</form>
Button 2 :
<form action="/yourServlet" method="POST">
<input name="id" type="hidden" value="2">
<input type="submit" value="delete 2">
</form>
Answered By - Mifmif
Answer Checked By - Mildred Charles (JavaFixing Admin)