Click to See Complete Forum and Search --> : Form with two buttons


jerryr125
11-10-2007, 10:38 AM
Hi !
Does anyone have an example of a form in which there is two 'submit' buttons ??
That is - submit button #1 executes a page or cgi script
and submit button #2 execute a TOTALLY different page or cgi script.

Any examples and/or example code would be appreciated !

thanks - jerry

scragar
11-10-2007, 11:44 AM
I don't know CGI, so I can't help you too much with that, but if you try the following script and check the URL bar after each submit button you should see the effect.

<form action="?" method="GET">
<p><input type="submit" name="submit" value="1" /></p>
<p><input type="submit" name="submit" value="2" /></p>
<p><input type="submit" name="cheese" value="3" /></p>
</form>
basicly which ever form button submits the form sends it's value, simple check and compair it then redirect acordingly.

felgall
11-10-2007, 02:11 PM
1. don't name your submit buttons "submit" or you break IE6+ which overlays the button reference over the submit function making it impossible to actually submit the form.

2. If you give all the submit buttons the same name then you can test the value that the field contains in the server side script to work out which button was pressed and what to therefore do. That is an easier test than testing if one of several different named fields exists.

jerryr125
11-10-2007, 03:51 PM
hi - basically the "method" will be "post" for either of the two buttons clicked.
I want to have the action changed based upon the button clicked.
that is :
if button1 is click, action1 is executed
if button2 is click, action2 is executed

does the make since ? thanks :) jr