Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning Parameters from Javascript to Java

 
Padmalatha Kontham
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic