castello
asked on
multiple submit buttons
I have a form with three submit buttons, each with different text. I am calling a script indicated in the FORM tag's action attribute. How can I tell which submit button was clicked? Is there a way to get the text of the button that was clicked?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
assuming the the script you want to run is on a different page:
use the following code for the buttons
<input type="Submit" name="Submit" value="text1">
<input type="Submit" name="Submit" value="text2">
<input type="Submit" name="Submit" value="text3">
MAKE SURE THAT ALL 3 BUTTONS HAVE THE SAME NAME
on the page with the script, you will have a variable $Submit that has the value "text1", "text2", or "text3"
You can use if/then or switch/case to perform actions based on the value of $Submit
use the following code for the buttons
<input type="Submit" name="Submit" value="text1">
<input type="Submit" name="Submit" value="text2">
<input type="Submit" name="Submit" value="text3">
MAKE SURE THAT ALL 3 BUTTONS HAVE THE SAME NAME
on the page with the script, you will have a variable $Submit that has the value "text1", "text2", or "text3"
You can use if/then or switch/case to perform actions based on the value of $Submit
Of course! As only 1 submit button can be pressed, they can all have the same name!
Regards,
Richard Quadling.
Regards,
Richard Quadling.
ASKER
paul13 and RQuadling (who answered before paul13), I tested both your solutions and they both work. These methods are easier than compustarsq's method would be.
I'm giving the points to RQuadling just because he was before paul13.
I'm giving the points to RQuadling just because he was before paul13.
of the button in a hidden field and can access the value
in next page. try it.