日期:2014-05-16  浏览次数:20356 次

请问为什么用request获不了值?
程序如下,文件名是gg.html,为什么访问http://localhost/gg.html?id=45   的时候,没有打出45出来,反而说网页上有错误?

<html   >
<head>

<meta   name= "ContentType "   content= "text/html "   />
<meta   name= "CharSet "   content= "GB2312 "   />

<table>

<tr> <td   colspan= "4 "> <input     type= "button "   value= "drawline "   onclick= "javascript:drawCanvas() "/> </td> </tr>
</table>

<script   language= "javascript ">
var   ff=Request.QueryString[ "id "];

function   drawCanvas()
{

Response.Write(ff);

}
</script>

</head>
<body>

</body>
</html>


------解决方案--------------------
<html>
<head>

<meta name= "ContentType " content= "text/html " />
<meta name= "CharSet " content= "GB2312 " />

<table>

<tr> <td colspan= "4 "> <input type= "button " value= "drawline " onclick= "javascript:drawCanvas() "/> </td> </tr>
</table>

<script language= "javascript ">
var ff=location.search;
ff=ff.substr(1,ff.length-1);
var paras = ff.split( "& ");
function getItem(id_name){
var a;
for(var i=0;i <paras.length;i++){
a = paras[i].split( "= ");
if(a[0]==id_name) return a[1];
}
return " ";
}
function drawCanvas()
{

document.write(getItem( "id "));

}
</script>

</head>
<body>

</body>
</html>