You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Campbell, Justin" <jc...@profilesys.com> on 2003/02/28 22:15:40 UTC
RE: can I pass a velocity variable to a javascript vairable?
Your example should work. For all the Javascript is aware of, you could have
just hard-coded that value in. Which brings me to my next point -- why
assign "var stringb" to the value of "${stringa}" ?? You should able to just
use ${stringa} wherever you would normally use stringb.
If you must use the approach you've given here, I would suggest doing
something like the following:
var stringb = "${stringa}";
In the example:
#set ($stringa = "asdf")
This would replace as:
var stringb = "asdf";
Hope this helps.
- Justin
-----Original Message-----
From: Keppel Yin [mailto:Keppel.Yin@microfocus.com]
Sent: Friday, February 28, 2003 4:17 PM
To: velocity-user@jakarta.apache.org
Subject: can I pass a velocity variable to a javascript vairable?
Hi,
Suppose I have the following code:
#set ( stringa = $request.getAttribute("a"))
<script language="javascript">
var stringb = $stringa;
</script>
The question is: is the above javascript statement valid?
Thanks,
Keppel
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org