• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

cancel button issue

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a JSP page there are two buttons - submit and cancel.
The first buton- submit is on a form named 'f' along with other input fields.
The second button is outside form 'f'.

This works fine so far.

Now I introduce third button - save. The save button needs to submit the form f and hence it needs to be in form 'f'.

If all three buttons are put in a row in form 'f' with cancel button in middle (user requirement), then cancel button is going to be in form 'f'.

For cancel action (hitting cancel button), I don't want to submit the form.

How can I keep cancel button in middle but preventing form f being submitted on cancel action?
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not even remotely a JSP issue.

Moved to the HTML forum.
 
Bear Bibeault
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jiju ka:

For cancel action (hitting cancel button), I don't want to submit the form.



Then don't make it a submit button.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Then don't make it a submit button.


I am looking for a solution.

I need to have button for cancel. The server needs to do some action but the form need not be submitted.

The contents of the input fields in the form should not be transfered to the server. It is OK to execute the doGet or doPost method of the servlet.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The server needs to do some action but the form need not be submitted



Well the only way that you can talk with the server is to post the page back to it. That is normally done with a form submission.

Eric
 
Bear Bibeault
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jiju ka:
The server needs to do some action but the form need not be submitted.



Again, don't make the cancel button a submit button and it will not automatically submit the enclosing form.

In the onclick handler for the non-submit button you can use Ajax to talk back to the server, or you can submit another (perhaps invisible form) to talk back to the server without submitting the "main" form.
 
reply
    Bookmark Topic Watch Topic
  • New Topic