aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Returning Parameters from Javascript to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Returning Parameters from Javascript to Java" Watch "Returning Parameters from Javascript to Java" New topic
Author

Returning Parameters from Javascript to Java

Padmalatha Kontham
Greenhorn

Joined: Jun 21, 2007
Posts: 6
Hi,

My requirement is to write a javascript for opening a confirm box on the click of a button. When the user clicks on "OK" button, the javascript should return a value "true" and when the user clicks on the "Cancel" button, "False" value should be returned.
I need to use these boolean variables outside the java script.
Is it possible for the javascript to return a value which can be used outside the script.


Please suggest me how to write the code for this.

Regards,
Padmalatha.K
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30352
    
150

Padmalatha,
var result = confirm(); stores the result in a Javascript variable. You can use these within other Javascript on the same page. You can also use JavaScript to set a hidden form field with the value and pass it to Java.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

You'll need to explain what you mean by "outside the script". As Jeanne pointed out, you can submit it back to the server via a form submission, but to go into more detail you'll need to be more specific.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning Parameters from Javascript to Java