如何将变量作为参数传递给javascript函数(How to pass a variable as a argument to javascript function)
我的jsp页面中有一个变量,我希望将其作为参数传递给javascript函数。如何做?
码:-
<% String ts=request.getParameter("testname"); session.setAttribute("tname", ts); Connection con=null; Statement s=null; ResultSet r=null; int t=60000; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:online_testing"); s=con.createStatement(); r=s.executeQuery("select * from "+ts+""); String time=r.getString("duration"); t=Integer.parseInt(time)*60000; } catch(Exception e1) { response.setContentType("text/html"); out.println(e1.toString()); } %> <body onload="setTimeout('submitForm()',<%=t%>)">它只取t的初始值,而不是更新的值。 如何将函数setTimeout()中的变量“t”的值作为参数传递?
I have a variable in my jsp page which i want to pass as an argument to a javascript function.How to do it?
code:-
<% String ts=request.getParameter("testname"); session.setAttribute("tname", ts); Connection con=null; Statement s=null; ResultSet r=null; int t=60000; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:online_testing"); s=con.createStatement(); r=s.executeQuery("select * from "+ts+""); String time=r.getString("duration"); t=Integer.parseInt(time)*60000; } catch(Exception e1) { response.setContentType("text/html"); out.println(e1.toString()); } %> <body onload="setTimeout('submitForm()',<%=t%>)">It is taking only the initial value of t,not the updated one. How can I pass the value of variable "t" in function setTimeout() as an argument?
最满意答案
修改您的代码如下
<% int i=1; %> <form name="ifrm" onsubmit="return validateform('<%=i%>')" action="Givetest" method="post"> //code </form>Modify your code as below
<% int i=1; %> <form name="ifrm" onsubmit="return validateform('<%=i%>')" action="Givetest" method="post"> //code </form>更多推荐
ts,<%,setTimeout,电脑培训,计算机培训,IT培训"/> <meta name="descripti
发布评论