aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how can i pass a javascript variable to a jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how can i pass a javascript variable to a jsp page" Watch "how can i pass a javascript variable to a jsp page" New topic
Author

how can i pass a javascript variable to a jsp page

naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

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

Joined: Jan 10, 2002
Posts: 61433
    
  67

Copy the value of the variable into a hidden input within the form.
[ May 20, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

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

Joined: Jan 10, 2002
Posts: 61433
    
  67

In the onsubmit handler for your form, assign the value of the variable to the value property of the input element.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can i pass a javascript variable to a jsp page