日期:2014-05-18  浏览次数:20727 次

高分求一简单问题,非常着急!!!!!!!!!!!!!!!!

String   parms   =   (String)request.getParameter( "parms ");

out.println(parms+ "eee ");

%>

<SCRIPT   LANGUAGE= "JavaScript ">
function   test(pars){
      alert( "alert ");
                }
</SCRIPT>


<html>
<body   onload= "test( <%=parms%> ); ">

<div   id   =   "url1 ">


<div>


我想把页面中传来的参数放到js中,上面这么写一直不行,应该怎么写的


------解决方案--------------------
不知道你的意思是不是这样?


<%
String parms = (String)request.getParameter( "parms ");

out.println(parms+ "eee ");

%>
<SCRIPT LANGUAGE= "JavaScript ">

function test(){
var a = <%=parms%> ;
alert(a);
}
</SCRIPT>


<html>
<body onload= "test(); ">

<div id = "url1 ">


<div>

</body>
</html>
------解决方案--------------------
<SCRIPT LANGUAGE= "JavaScript ">
function test(pars){
alert( "alert ");
}
</SCRIPT>
这段js好像根本跟参数无关,是不是这里写错了?
------解决方案--------------------
Theface(网络白客) ( ) 信誉:98 Blog 加为好友 2007-05-09 17:56:18 得分: 0


假如我们把变量parms的值想像成 "AAA ";
<body onload= "test( <%=parms%> ); "> == <body onload= "test(AAA); "> 试问这句话在什么时候可以执行?
只有在这个onload事件触发前声明了AAA这个变量.
所以你要把这个传入的参数变成字符串:
<body onload= "test( ' <%=parms%> '); "> == <body onload= "test( 'AAA '); ">


同意,加 ' '试试,不行就 " "再试
------解决方案--------------------
<%@ page language= "java " import= "java.util.* " pageEncoding= "gbk "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'MyJsp.jsp ' starting page </title>
<SCRIPT LANGUAGE= "JavaScript ">
function test()
{
var temp = document.getElementById( "hi ").value;
alert(temp);
}
</SCRIPT>
</head>

<body onload= "test(); ">
<input type= "hidden " value= "${param.test} " id= "hi "/>
</body>
</html>