File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 60053
    
  65

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: 60053
    
  65

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
 
Similar Threads
compare jsp variable and javascript variable
Logic tags
How to access javascript variable of one file in another jsp file
How to refer a java variable in javascript code.
How do you set a javascript variable from jsp?