• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass struts 2 variable to a javascript method

 
Sona Andrews
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<script type="text/javascript">
var myVarType = '<s:property value="="#myVar"" escapeXml="true"/>'
</script>
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic