Use input-submit to represent multiple options
I have a table of events on a page. Last column contains available actions, i.e. "accept", "tent. accept", "cancel".
So if you are an attendee you'll get "accept"/"tent. accept" buttons. If you are the organizer you have "Cancel" option.Now, I have done "Cancel" as <input type='submit'...
element, and put "accept"/"tent. accept" as links. That's not actually bad, but still pretty evil. I'd rather use input/submit consistently, but still keep one-click operations (i.e. I don't want to have selection-box AND a submit button).
E.g. Bob will see:
| Topic | Time | Organizer | Actions |
| Stuff | 2:00 | Bob | [Cancel] |
And Jane, who was invited on the same meeting, will see:
| Topic | Time | Organizer | Actions |
| Stuff | 2:00 | Bob | [Accept] [Tent. Accept]|
Question again is: How do I implement two buttons for Jane's choice, so that each button is still a <input type='submit'...
The names (and values) of your submit buttons should be available to your server-side script so that you can take different actions. Here's a full explanation: http://www.javascript-coder.com/html-form/html-form-submit.phtml
you can use it with one form. Differenciate it with the name
<form action="" method = "post">
<input type='submit' name = "sub_button" value="Cancel">
<input type='submit' name = "sub_button" value="Accept">
<input type='submit' name = "sub_button" value="tent">
</form>
if($_POST['sub_button'] == 'Cancel') {
....
} else if($_POST['sub_button'] == 'Accept') {
....
} else if($_POST['sub_button'] == 'tent') {
....
}
精彩评论