@xiian said:
While AJAX would do the trick here nicely, this can be solved with straight HTML (and a good amount of thought in the processing page. It could even be done with a single form.
To go with the one form per row concept, you start a new form on every row, with the action being the same for all (or maybe you could pass the row ID as a URL parameter) then you have 7 submit buttons. Each submit button has the same name (perhaps 'action') and the various values as needed ('Pick Up', 'Deliver', etc)When the user clicks on a button, the form is submitted, the processing page gets the row ID (from either the URL or the hidden form element) and then checks to see what it should be doing by looking at the value of 'action'. Then processes accordingly.
Straight-forward HTML with no Javascript and a minimum of markup. As for the one form per page idea, you would just have to append the row ID to either the name of the submit button, preferably in the form of 'action[$rowID]' so this way it shows up as an array. Then on the processing page, we can parse that out of the submitted data.foreach ($_POST['action'] as $id=>$action) { // Do whatever you want in here. // This will only really go through these lines once }
So it's possible to do this with straight XHTML and some good PHP.
It may be easily possible on the server side but not on the client side. The problem is that due to HTML's usual awesome non-logic, you can't make a form per row. If you wanted to, you would need to put the <form> element between the <table> and <tr> or between the <tr> and <td> tags:
(Method 1)
<table>
<form action="handle.php?row=1">
<tr>
<td>
Cell 1,1
</td>
<td>
Cell 1,2
</td>
</tr>
</form>
<form action="handle.php?row=1">
<tr>
<td>
Cell 2,1
</td>
<td>
Cell 2,2
</td>
</tr>
</form>
</table>
(Method 2)
<table>
<tr>
<form action="handle.php?row=1">
<td>
Cell 1,1
</td>
<td>
Cell 1,2
</td>
</form>
</tr>
<tr>
<form action="handle.php?row=2">
<td>
Cell 2,1
</td>
<td>
Cell 2,2
</td>
</form>
</tr>
</table>
Unfortunately both methods are invalid HTML (don't even start with XHTML), because only the special table handling tags may be between a <table> and a <td>.
Basically, if you want your HTML still to validate, you have two choices: Wrap the form around the whole table or put one into each cell like our guy did. That's it.
Of course validity isn't everything. It's just that you get into the realm of obscure browser bugs and undefined behavior that way...