admin管理员组文章数量:1384349
I have one in jsp page.
i want to pass this value as argument of java script function call
my jsp apge code is:
<input type="submit" onclick="play(<s:property value="vname"/>)">
my java script function code:
function play(n)
{
alert(n);
}
please help me to solve this problem;
regard
Rohit kachhadiya
I have one in jsp page.
i want to pass this value as argument of java script function call
my jsp apge code is:
<input type="submit" onclick="play(<s:property value="vname"/>)">
my java script function code:
function play(n)
{
alert(n);
}
please help me to solve this problem;
regard
Rohit kachhadiya
Share Improve this question asked Sep 20, 2012 at 7:23 Rohit R.K.Rohit R.K. 2972 gold badges4 silver badges14 bronze badges3 Answers
Reset to default 1You have to wrap struts tags with quotes:
<input type="submit" onclick="play('<s:property value="vname"/>')">
otherwise the value of "vname" will be interpreted as a JavaScript variable, not a string!
Using struts2 tag:
<s:submit onclick="javascript:play('%{vname}')" />
Agree with daveoncode, apart from that In your js, get it directly like
var varName = document.forms[0].name/id.value;
Or you have one more option to write inline js and pass value of your element. But its a bad practice.
本文标签: struts2 property value as argument of javascript functionStack Overflow
版权声明:本文标题:struts2 property value as argument of javascript function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744531338a2611055.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论