开发者

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).

开发者_如何转开发Assume user has JS disabled.

Should I create two forms for accept/tent case? or is there a better solution?

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') {
....
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜