Forums Register Login

Get the button value from request.getParameterValues()

+Pie Number of slices to send: Send
I have a jsp page that contains a form.
In the form i have several fields and buttons.
I am able to get the values from the fields but now I also want to know witch button that was pressed.
How do I do that?
/Jle
+Pie Number of slices to send: Send
Assuming that the buttons are of type "submit", the easiest way is to just give them all the same name with differing values as in:

You will get a single request parameter named "theButton" which will have the value of the clicked button as its value.
However, since the values are visible (they serve as the caption of the button), you may not be able to have unique values (if all the buttons need to be captioned "OK", for example). In this case you could use unique names for each of the buttons and look through the list of request parameters to see which one got submitted.
If your buttons are not submit buttons, you might have to resort to a small bit of JavaScript.
hth,
bear
[ March 17, 2003: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
 


I am able to get the values from the fields but now I also want to know witch button that was pressed.



Cheers-
- Marty
+Pie Number of slices to send: Send
Thank you, it helped!
We don't have time to be charming! Quick, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 9275 times.
Similar Threads
validation particular fields for different actions in a single page
Struts 1.1 refresh with values
Is it possible?
Dynamic field collapse issue in Form
clearing HTML form fields after return from struts validation with errors
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:30:14.