我有这样的代码片段::将Scriptlets中的变量传递给Javascript。
<script type="text/javascript">
function gotoa(){
<%!
public void a(){
String temp1;
PopulateTextbox obj = new PopulateTextbox();
temp1 = obj.method();
request.setAttribute("variable", temp1);
}
%>
var myVar = <%=request.getAttribute("variable")%>
}
</script>
我想要做的是让我的JavaScript函数gotoa变量temp1中的值()。在这个特殊的代码我得到一个错误无效请求
request.setAttribute("variable", temp1);
我的主要目的是为了让我的脚本让代码再次运行和新鲜值在变量传递给调用函数A()上的一些按钮单击事件temp1目录。然后它将传递给gotoa()以充当我的数据网格的源(不在此代码中)。基本上我想刷新一些按钮点击网格。我做对了吗?请帮忙。谢谢。
将'temp1'的值设置为隐藏字段,并在Javascript中访问此隐藏字段的值。 – Lion 2012-03-14 09:36:25
如何做那个狮子? – 2012-03-14 09:37:52
'”>'。你现在可以像这样'document.getElementById('tempValue')。value;'' – Lion 2012-03-14 09:40:39