You can also say
<input type="submit" name="p_action" value="Save">
<input type="submit" name="p_action" value="Done">
<input type="submit" name="p_action" value="Next">
<input type="submit" name="p_action" value="Previous">
and in the servlet say
public class AppConstants{
// constants class
public final static String PREVIOUS = "Previous";
public final static String DONE = "Done";
...
}
String action = request.getParameter ("p_action");
if (p_action != null){
if (p_action.equals(AppConstants.PREVIOUS)){
// do something
} else if ..
}
Thor HW
----- Original Message -----
From: TaNiA <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 08, 2000 7:19 PM
Subject: Re: How to know which form button was pressed?
> Another method if you don't want to use javascript is to just use
> the "NAME" attribute in your HTML form..
>
> eg.
> <input type="SUBMIT" NAME="btn_1" VALUE="First button">
> <input type="SUBMIT" NAME="btn_2" VALUE="Second button">
>
> then in your servlet, you can just do a
>
> String btn_1 = request.getParameter ("btn_1");
> String btn_2 = request.getParameter ("btn_2");
>
> if (btn_1 != null)
> {
> // user has clicked on btn_1
> }
> else
> {
> // user has clicked on btn_2
>
> }
>
> hope this helps,
> tania
>
>
> ----- Original Message -----
> From: Eike Hirsch <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, March 08, 2000 4:08 PM
> Subject: Re: How to know which form button was pressed?
>
>
> Hi,
> Try this:
> 1st add a hidden field into the form
> <input type=hidden name=button value="">
> 2nd you'll need a JavaScript-function that changes the value of the hidden
> field
> (depending on the given parameter) and submits the form.
> function submitForm(button) { ... }
> 3rd change your submitbuttons into normal ones and add an onClick-method
> which
> will run the funktion.
>
> hope this helps
> eike
>
> Jose Miguel Rodriguez schrieb:
>
> > Hello all,
> >
> > I'm developing a mini applications server for internal purposes, and now
> I'm
> > facing with a problem: suppose I have the following html code:
> >
> > <form action=/servlet/.....>
> > <input type="SUBMIT" NAME="btn_1" VALUE="First button">
> > <input type="SUBMIT" NAME="btn_2" VALUE="Second button">
> > </form>
> >
> > How do I know when user press the 1st or the 2nd button?
> >
> > Thanks in advanced
> >
> > --
> >
> > saludos,
> > jmiguel
> >
> > Virtual Software,
> > http://www.virtualsw.es/
> > ICQ 13550064
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html