By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

accesing JavaScript variable in JSP.

P: n/a
ak
Hi,

I want to access JavaScript in JSP.

My problem is - I am getting a value from a combo box and using
this value to set value of a variable in JS function. I want to use
this variable in JSP so that i can do further processing based on the
value I get from this variable.

Hope I am clear, please help if u know the solution.

Thanks,

AK
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 27 Dec 2004 22:44:12 -0800, ak wrote:
I am getting a value from a combo box and using
this value to set value of a variable in JS function. I want to use
this variable in JSP so that i can do further processing ..


Post it to the page that does the processing.
(And note that this has as much to do with JSP as PHP or ASP,
since JSP's end up as HTML).

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2

P: n/a
Lee
ak said:

Hi,

I want to access JavaScript in JSP.

My problem is - I am getting a value from a combo box and using
this value to set value of a variable in JS function. I want to use
this variable in JSP so that i can do further processing based on the
value I get from this variable.


Do you mean that you want the value after the form has been submitted, or
before?

Jul 23 '05 #3

P: n/a
what he means is that the JSP is already compiled and sent by the time
it reaches the client and the javascript is run.
So, you have to send it back to your server running the JSP so it can
process it.
There are two ways of sending back data post and get, in a nutshell
what that really means is either it's tacked onto the end of a URL like
http://www.thephred.com?matt=wonderful

or it's hidden from the end user. (The example is a get)
how do you code for it?

well if you have no form just change your document location like:

document.location.href = "http://www.thephred.com?" + key + "=" +
value;

if you have a form and the action is post put in a hidden input field

<input type="hidden" name="matt" value="wonderful" />

you can then change that value with javascript and submit the form.
hope that makes sense...
;-)

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.