How can we program 2 Submit buttons on a Form. This is is needed for example when we have a poll form where the user is asked to either press 'Vote' or 'Show Results'. We need different PHP script files to run when each button is pressed. Is this possible ?
Ofcourse there is a work around... Let 'Vote' be a submit button and 'Show results' be a hyperlink.
Best Regards.
Hey Jay!
There is another way around it: Use one form field for each button.
This is not optimal, but it works!
Of course, if anyone has an optimal solution, I would like to see it - since I have the same problem! ;o)
-Mikkel
erm, well how about this...
one button called vote, one called show
if ($vote) {vote stuff here} elseif ($show) {show stuff here}
should work, let me know anyways please!
I do this all the time; just give each button a different name.
Yes, simply the following:
if ($vote) { // do something }
if ($show) { // do something else }
Just make sure your buttons have the correct values for the above mentioned.
Thanks to everyone.
It worked. I should have thought of it myself. Sill me.
Hi, I have seen a lot of questions regarding submit buttons and how to go about having more than one button on a form , the code below will have 2 buttons open up two seperate pages that you define..
<INPUT TYPE="button" VALUE="Open Outage" onClick="parent.location='http://www.your.page.here.com'"> <INPUT TYPE="button" VALUE="Open Outage" onClick="parent.location='http://www.your.other.page.here.com'"> I hope this helps someone. if it does send me a mail saying hi from where ever you are ;o)
This works great! thanks man.
I am looking to be able to do something like this. <INPUT TYPE="button" VALUE="Open Outage" onClick="parent.location='http://www.your.page.here.com'">
Except I need it to call a separate php function in a different php file. Does anybody know if you can call a function when a button is selected?
Thanks B-