accesing value data using request
I have form with two buttons having same name but different values ,how to get the value of both the buttons having same name but different value using request ?
<form action="controller">
<input class="smallbutton" name="op" value="login" type="submit"/>
<input class="smallbutton" name="op" value="SignUp" type="submit"/>
</form>开发者_JS百科;
request.getParameter("op")
gives only the value of login but not sign up.
I can't imagine why would you need such a thing. Two options, depending on what you are trying to acheive:
- use
request.getParameterValues("op")
- use
<input type="hidden" value=".." />
and change the value using javascript according to your usecase.
Please clarify what's the bottom-line, i.e. what are you trying to do.
i think it depends whether you click on "SignUp" or on "login".
Since you cannot click on 2 buttons on 1 formular, you cannot get the 2 values
request.getParameter("op") gives only the value of login but not sign up.
This makes perfect sense. It returns the value of the pressed button. If you press Sign up
then it will return signup
. This way you know exactly what to do in the server side: login or signup. I really don't see any business reason why you would like to get the value for the both buttons regardless of the button pressed.
精彩评论