This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes cancel button issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "cancel button issue" Watch "cancel button issue" New topic
Author

cancel button issue

jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Not even remotely a JSP issue.

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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

Joined: Oct 12, 2004
Posts: 306

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.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cancel button issue