Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i pass a javascript variable to a jsp page

 
naro pad
Ranch Hand
Posts: 58
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one jsp page which has on it some javascript.Within the javascript I have one variable and I want that variable after submitting the form to passed as a parameter to the submitted jsp

How can I do that?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copy the value of the variable into a hidden input within the form.
[ May 20, 2008: Message edited by: Bear Bibeault ]
 
naro pad
Ranch Hand
Posts: 58
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because I'm a beginner can you explain me a little more...

I have this
<script>
var times;
function(){
times++;
}
</script>
...
<form>
...
<input type="submit" value="Save"/>
<input type="hidden" value=" ? "/>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the onsubmit handler for your form, assign the value of the variable to the value property of the input element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic