This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Two actions in single button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Two actions in single button click" Watch "Two actions in single button click" New topic
Author

Two actions in single button click

chennai Kumar
Ranch Hand

Joined: Jun 04, 2005
Posts: 72
My requirement is when user clicks submit button two business should execute, that is two actions should perform in single button click.

In java script i executed the below code when the user clicks the submit button.



In the validate method, list of values should validate in external system and display the message as Amount is validated in the screen.

In the PDFOpen method open the PDF document in separate window based on validation of data(dynamic data )

Here the problem before the validate method complete PDFOpen method s executing, so that PDF document is opening before the validation. Could you please suggest how to design for the requirement.

Thanks in Advance.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Once you submit the form, control passes to the servlet and the page is unloaded, so you can't submit the form again as the code after the submission will never execute.

If you want to make multiple submissions from the page without unloading that page, you'll need to use Ajax.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chandraprakash Sarathe
Greenhorn

Joined: Jan 21, 2012
Posts: 16
Why not handle all these two actions in Servlet on click of Button ? Ajax too could give you same problem (PDF document is opening before the validation) , might be synchronizing Ajax call can help you.


Chandraprakash Sarathe
http://javaved.blogspot.com
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
OR submit the page to one place and have the server make the second call.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two actions in single button click
 
Similar Threads
Bypassing form validation
accessing request scope variable from javascript
Struts parent & popup window with validator framework
How to do Client-side validation in Javascript in Struts Form Submission.
intermediate submit and validation of a form