关于Window.open [总结]

来源:互联网 发布:mac wifi未安装硬件 编辑:程序博客网 时间:2024/06/13 19:04

此为工作中总结出的。

于父页面oc1栏位输入值,当失去焦点时打开自页面。于子页面中连接数据库查询其他相关信息,然后传值回父页面。此为达到一个数据中转的功能。其他,如:验证,传值等可于同等方法下改写即可。(已通过测试)
父页面
<input type="text" name="oc1" onblur = "openwindow();">
<input type="text" name="oc2">
<input type="text" name="oc3">
<input type="text" name="oc4">
<input type="text" name="oc5">
<script language="javascript">
function openwindow()
{
 var c1 = document.getElementById("oc1").value;
 var URL = "new.asp?LotID=" + escape(c1);
 window.open(URL,'New_window','height=100; width=200; resizable=0; scrollbars=0; toolbar=0;top=0;left=0;status=0');
}
</script>
标注:escape()为把其中参数转换成为Unicoal型别 

子页面
<HTML><BODY>读取中(Retrieve Data)...</font>
<SCRIPT LANGUAGE="VBScript">
Dim con,sSQL
<%
 LotID = Request("LotID") '取出主表单所传过来的值
 '连接数据库
 Set con = Server.Createobject("ADODB.Connection")
 con.Open("Driver={SQL Server};Server=数据服务器地址;UID=用户名;PWD=密码;Database=数据库名称")
 set rs=server.createobject("ADODB.Recordset")
 sql="select prod_id,lottype,qty,priority from NonProdBankInOutLotInfo_v where lot_id='" & LotID & "'"  '查询所需数据
     rs.open sql,con,3,1 
 
 if not rs.eof then
%>
 opener.document.getElementById("oC2").value = "<%=rs("lottype")%>"
 opener.document.getElementById("oc3").value = "<%=rs("prod_id")%>"
 opener.document.getElementById("oc4").value = "<%=rs("priority")%>"
 opener.document.getElementById("oc5").value = "<%=rs("qty")%>"
<%
 set rs = Nothing
 con.close
 set con=Nothing

 else
%>
    msgbox "Invalid LotID, please try again!" 
<%
 end if
%>
self.close
</SCRIPT>
</BODY></HTML>  

原创粉丝点击