javascript vars into jsp
I have a select control with an onclick event. This event fires a js function that gets the selected value as a js var. Now i want to set the value of this js var into my jsp as say a page scoped property so that it can be used in the page after the selection is made.
I've tried setting the value using the DOM into a 'hidden' field, but I do not need to submit a request at this point. I just want to use the var value in the jsp for further calcs etc... before the request is submitted.
Any suggestions welcome...
[538 byte] By [
largomana] at [2007-11-27 11:59:26]

# 2
Exactly, the only way to use it that value before submitting the form, on the jsp, is calling via JS an AJAX function to process that variable in the background maybe to put it as a session variable so you can use it after that anywhere else on your app...
The AJAX framework i use for this is JackBe's NQ Suite, wich really helps to make it to easy to create these kinds of ajax calls... hope this info helps...
greetings!
Adrian
# 3
> I have a select control with an onclick event. This
> event fires a js function that gets the selected
> value as a js var. Now i want to set the value of
> this js var into my jsp as say a page scoped property
> so that it can be used in the page after the
> selection is made.
>
> I've tried setting the value using the DOM into a
> 'hidden' field, but I do not need to submit a request
> at this point. I just want to use the var value in
> the jsp for further calcs etc... before the request
> is submitted.
No you cannot. jsp executes on the server, generating html and javascript which then gets streamed to the browser. The javscript then executes on the browser. At this point, the jsp is nowhere in the picture.
You'll have to send a new request back to the same jsp and the whole cycle restarts .
You can set it as a javascript variable.
cheers,
ram.