(javascript off topic) form with two submit buttons ?

Discussions

Web tier: servlets, JSP, Web frameworks: (javascript off topic) form with two submit buttons ?

  1. Hi,

    I have a form in a jsp file that has :

    1)Drop down list (for names)
    2)textarea ( for comment)


    I want to have two submit buttons (chekin, checkout), who to do it please ?
    thanks
  2. You can put two buttons and then control the action of the form in the onClick javascript event of the button, something like this:

    <input name="button1" type="submit" onclick="form.action='Action1';form.submit();">
    <input name="button2" type="submit" onclick="form.action='Action2';form.submit();">


    Bye ~P
  3. while the onclick will allow you to control action within the jsp page in a javascript function, the servlet needs to grab the info from the submit buttons which should be named differently. This way you can determine which action to take depending on which button was selected.