将JSP变量作为参数传递给javascript函数 [英] Pass a JSP variable as parameter to javascript function
本文介绍了将JSP变量作为参数传递给javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在head的脚本标记内定义了一个函数.(在JSP中) 我想在JSP中声明一个字符串变量,并将其作为参数传递给此函数
I have a function defined inside the script tags of head.(in a JSP) I want to declare a string variable in the JSP and pass it as a parameter to this function
<% String uname ="multiple"; %>
<form action="ExampleServlet" method="post" onclick="pagetype(${uname});"><br>
<input type="submit" name="Log in" value="Login" />
</form>
但这不起作用. 需要帮助
But this doesn't work. need Help
推荐答案
您必须像这样使用
<% String uname ="multiple"; %>
<form action="ExampleServlet" method="post" onclick="pagetype('<%=uname%>');"><br>
<input type="submit" name="Log in" value="Login" />
</form>
这篇关于将JSP变量作为参数传递给javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文