wood burning stoves 2.0*
The moose likes Struts and the fly likes How to pass struts 2 variable to a javascript method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to pass struts 2 variable to a javascript method" Watch "How to pass struts 2 variable to a javascript method" New topic
Author

How to pass struts 2 variable to a javascript method

Sona Andrews
Greenhorn

Joined: Nov 05, 2011
Posts: 1

I need to pass a struts 2 variable to a javascript function as a parameter. Below is the sample code which I had tried

<select id="lstLivingInHome1"
onchange="ShowHideLivingArrangement(<s:property value="#myVar"/>)"
listKey="referenceCode" listValue="referenceCodeDesc"
headerKey="-1" headerValue="" list="yesNoList" />


Can anyone please tell me how can I do that?

Regards,
Sona
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

<script type="text/javascript">
var myVarType = '<s:property value="="#myVar"" escapeXml="true"/>'
</script>

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Alternatively if you have the value in a HTML FORM element, you can fetch the value using Javascript

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass struts 2 variable to a javascript method