Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to pass struts 2 variable to a javascript method

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

 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic