首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

新手请问:小弟我写的页面间传值代码不知错在那里

2012-02-20 
新手请教:我写的页面间传值代码不知错在那里?formname form1 inputname rq1 type text id r

新手请教:我写的页面间传值代码不知错在那里?
<form   name= "form1 ">
<input   name= "rq1 "   type= "text "     id= "rq1 "     value= "2007-01-01 "   >
<input   name= "rq2 "   type= "text "     id= "rq2 "     value= "2007-03-31 "   >
<input   name= "Submit "   type= "button "   value= "按钮 "   onClick= "window.open( 'test1.asp?id1= <%=request.form( "rq1 ")%> &id2= <%=request.form( "rq2 ")%> ', 'newWindow ', 'menubar=no,scrollbars=no,resizable=no,width=800,height=380 ');return   false; "   >

为什么在test1.asp中取不出数?
<%
response.write   Request.QueryString( "id1 ")
%>
<%
response.write   Request.QueryString( "id2 ")
%>

[解决办法]
asp的代码是在那个onClick的javascript生成之前执行的,此时Request.Form为空,所以那个onClick就变成 "...test1.asp?id1=&id2= ... ",你表单嘛只要把form的action= "test1.asp " method= "GET ",onClick删掉,就可以在test1.asp中看到id1和id2了
[解决办法]
<form name= "form1 ">
<input name= "rq1 " type= "text " id= "rq1 " value= "2007-01-01 " >
<input name= "rq2 " type= "text " id= "rq2 " value= "2007-03-31 " >
<input name= "Submit " type= "button " value= "按钮 " onClick= "window.open( 'test1.asp?id1= '+form1.rq1.value+ '&id2= '+form1.rq1.value+ ' ', 'newWindow ', 'menubar=no,scrollbars=no,resizable=no,width=800,height=380 ');return false; " >
</form>

热点排行