请问一个有关传递参数的问题?

xhping801216 2003-05-24 06:52:28
outsingle.asp
<%@Language=VBScript%>
<!--#include file ="../inc/conn.asp"-->
<!--#include file ="../inc/adovbs.inc"-->
<%' If Trim(request("flag"))<>"1" Then %>
<html>
<head>
<title>填写外出单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../inc/main.CSS" type="text/css">
<script language="javascript">
function checkunitname()
{
if (event.keyCode==13)
{
event.keyCode="#0";
var Citycode="0001";
var ProvinceCode="01";
var UnitSSN1=document.form1.unitname.value;
window.open('returnunitname1.asp?spellcoding='+UnitSSN1+"&Citycode="+Citycode+"&ProvinceCode="+ProvinceCode,'register','left=180,top=255,width=250,height=380,status=no,toolbars=no,menubars=no,scrollbars=auto,resize=no');

}
return true;
}
function kb()
{
if(event.keyCode==13)
event.keyCode=9;
}
</script>
<script>
//自动最大化
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<form name="form1" method="post" action="AddOutSingle_result.asp" onkeydown="kb()">
<table width="600" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#FF9900">
<tr bgcolor="#FFFFFF">
<td height="19" colspan="4">
<div align="center"><font color="#FF0000"><b>填写外出单</b></font></div>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="108">外出人员</td>
<td width="201">
<input type="text" name="CompanyPerson" value=<%=Session("Username") %>>
</td>
<td width="59">外出时间</td>
<td width="203">
<%
OutSingleTime=date&" "&time
%>
<input type="text" name="OutSingleTime" value="<%=OutSingleTime %>">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="108" height="19">单位名称</td>
<td colspan="3" height="19">
<input type="text" name="unitname" onkeydown="checkunitname()">
(输入单位简拼,点击回车,即可出现所需要的单位名称) </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="108">单位联系人</td>
<td width="201">

<input type="text" name="ClientDutyPerson">
</td>
<td width="59">外出地点</td>
<td width="203">
<input type="text" name="Address" value="">
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width="108">外出原因</td>
<td colspan="3">
<input type="text" name="OutSingleReason" maxlength="255" size="60">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="4">
<div align="center">
<input type="button" name="Add" value="增加" onclick="javascript:form1.submit()">
  
<input type="reset" name="Submit2" value="重写">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
<%
Conn.Close
Set Conn=Nothing
%>
returnunitname1.asp
<%@Language=VBScript%>
<!--#include file ="../inc/conn.asp"-->
<% If (trim(request("ProvinceCode"))="" and trim(request("Citycode"))="") Then %>
<script language="javascript">
alert("请选择省市");
self.close();
</script>
<% Else %>
<%
Sql="select * from unitbaseinfo where spellcoding like '"&trim(request("spellcoding"))&"%' and (ProvinceCode='"&trim(request("ProvinceCode"))&"' and Citycode='"&trim(request("Citycode"))&"')"
set rs=server.createobject("adodb.Recordset")
rs.open sql,conn,1,3


%>
<html>
<head>
<title>查询单位名称</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function check(t,s,m){
opener.document.form1.Address.value=m;
opener.document.form1.ClientDutyPerson.value=s;
opener.document.form1.unitname.value=t;
self.close();
}
</script>
<link rel="stylesheet" href="../inc/main.CSS" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="218" border="0" cellspacing="1" cellpadding="3" bgcolor="#FF6600">
<tr bgcolor="#FFFFFF">
<td width="17"> </td>
<td width="126">单位名称</td>
<td width="53">单位简拼</td>
</tr>
<% If Not Rs.Eof Then
Sql2="select * from personnalbaseinfo where unitssn='"&Rs("unitssn")&"' and (ProvinceCode='"&trim(request("ProvinceCode"))&"' and Citycode='"&trim(request("Citycode"))&"')"
response.write sql2
set rs2=server.createobject("adodb.Recordset")
rs2.open sql2,conn,1,3
%>
<% While Not Rs.Eof
%>
<tr bgcolor="#FFFFFF">
<td width="17">
<input type="radio" name="unitname" value="<%=Rs("unitname")%>" onclick="check('<%=Rs("unitname") %>','<%=Rs2("personnalname")%>','<%=Rs("Address") %>')">
</td>
<td width="126"><%=Rs("unitname")%></td>
<td width="53"><%=Rs("spellcoding")%></td>
</tr>
<% Rs.Movenext
Wend
Rs.Close
Set Rs=Nothing
%>
<% Else %>
<tr bgcolor="#FFFFFF">
<td colspan=3>没有此单位</td>
</tr>
<% End If %>
</table>
</form>
</body>
</html>
<% End If %>
我现在实现的功能是:在单位名称一栏中输入单位的简拼,点击回车之后,在弹出的窗口
returnunitname1.asp中出现与之相关的几个单位名称,点击前面的单选按钮后,单位名称(汉字)和相应联系人和单位地址自动的出现在相应的输入框中
我现在遇到的问题是,一个单位有可能出现多个的联系人,我如何将多个的联系人都显示到单位联系人一栏中。
说明:unitbaseinfo是单位基本信息表、personnalbaseinfo是联系人基本信息表
...全文
67 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
seabell 2003-05-26
  • 打赏
  • 举报
回复
person=person+rs2("personnalname")+";"
seabell 2003-05-26
  • 打赏
  • 举报
回复
<% If Not Rs.Eof Then
%>
<% While Not Rs.Eof

Sql2="select * from personnalbaseinfo where unitssn='"&Rs("unitssn")&"' and (ProvinceCode='"&trim(request("ProvinceCode"))&"' and Citycode='"&trim(request("Citycode"))&"')"
response.write sql2
set rs2=server.createobject("adodb.Recordset")
rs2.open sql2,conn,1,3
dim person
person=""
While Not rs2.Eof
person=person+rs2(personnalname)+";"
rs2.Movenext
Wend
rs2.Close
Set rs2=Nothing
%>
<tr bgcolor="#FFFFFF">
<td width="17">
<input type="radio" name="unitname" value="<%=Rs("unitname")%>" onclick="check('<%=Rs("unitname")%>','<%=person%>','<%=Rs("Address")%>')">
</td>
<td width="126"><%=Rs("unitname")%></td>
<td width="53"><%=Rs("spellcoding")%></td>
</tr>
<% Rs.Movenext
Wend
Rs.Close
Set Rs=Nothing
%>
<% Else %>
<tr bgcolor="#FFFFFF">
<td colspan=3>没有此单位</td>
</tr>
<% End If %>
YP2002CN 2003-05-26
  • 打赏
  • 举报
回复
for (var intLoop = 0; intLoop < document.UserInfo.length;intLoop++)
YP2002CN 2003-05-26
  • 打赏
  • 举报
回复
我的建議
如果要將多個值來回傳送於對話框方塊及建立的視窗之間,應該使用陣列或者物件.下面給你個例子代碼,用來要求多個資訊以及如何傳送多個資訊回應用程序.
<HTML>
<HEAD>
<TITLE>User Information</TITLE>
<STYLE TYPE="text/css">
BODY {margin-left:lOpt; background:menu}
</STYLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
function saveValues() {
var retVal = new Array;
for (var intLoop = 0; intLoop < document.userInfo.length;intLoop++)
with (document.UserInfo[intLoop])
if (name !="")
retVal[name] = value;
window.returnValue = retVal;
event.returnValue = false;
window.close();
}
</SCRIPT>
</HEAD>
<BODY>
<!--此表單是用於把內容含有控制項組合而成一容易讀取得陣列 -->
<FORM NAME="UserInfo">
<FILEDSET>
<LEGEND>User Information</LEGEND>
<P>User Name: <INPUT TYPE=TEXT NAME="User">
<P>address: <TEXTAREA ROWS="3" NAME="address"></TEXTAREA>
</FILEDSET>
</FORM>
<P STYLE="text-align:center>
<INPUT TYPE=SUBMIT STYLE="width:5em" ONCLICK="saveValues();" VALUE="OK>
<INPUT TYPE=RESET ONCLICK="window.close();" VALUE="Cancel">
</BODY>
</HTML>
假如上面檔案是在一個UserInfo.htm檔案裡面.也就相當於你的window.open里得內容
下面程序是把上面傳回得信息顯示在一個獨占方式得對話快中.然後循環報告回傳值:
<SCRIPT LANGUAGE="JavaScript">
var vals = new Array();
vars = window.showModalDialog("UserInfo.htm");
if (vals != null) {
strOut = "Returned values:";
for (name in vals)
strOut += "\n"+name+" = "+vals[name];
alert(strOut);
}
</SCRIPT>
xhping801216 2003-05-26
  • 打赏
  • 举报
回复
我快急死了
xhping801216 2003-05-26
  • 打赏
  • 举报
回复
请大家快快帮忙啊,是不是我说的不清楚 呢
seabell 2003-05-26
  • 打赏
  • 举报
回复
因为退出循环前select多加了一次长度,所以要减掉
seabell 2003-05-26
  • 打赏
  • 举报
回复
将主页面中input改为select
<td width="108">单位联系人</td>
<td width="201">
<select name="ClientDutyPerson"><option></option></select>
</td>
xhping801216 2003-05-26
  • 打赏
  • 举报
回复
谢谢 seabell(百合心)
我还有一个小小的请求
请问opener.document.form1.ClientDutyPerson.options.length--;是什么意思
seabell 2003-05-26
  • 打赏
  • 举报
回复
<script language="javascript">
function check(t,s,m){
opener.document.form1.Address.value=m;
ClientDutyPerson=s.split(";");
for(i=0;i<ClientDutyPerson.length-1;i++)
{
opener.document.form1.ClientDutyPerson.options[i].value=ClientDutyPerson[i];
opener.document.form1.ClientDutyPerson.options[i].text=ClientDutyPerson[i];
opener.document.form1.ClientDutyPerson.options.length++;
}
opener.document.form1.ClientDutyPerson.options.length--;

opener.document.form1.unitname.value=t;
self.close();
}
</script>
xhping801216 2003-05-26
  • 打赏
  • 举报
回复
to : YP2002CN(老婆我不敢了,老婆我愛你) ( ) 你的我也试过了,便不太明白
xhping801216 2003-05-26
  • 打赏
  • 举报
回复
to : seabell(百合心);你的方法既然能将所有的联系人显示出来,但不是我想要的情况,我想要的是:联系人后要最后以下拉框的形式显示
xhping801216 2003-05-25
  • 打赏
  • 举报
回复
是的,我想知道如何将returnunitname1.asp页面所有的联系人都返回到addOutSingle.asp页面
返回去之后又如何显示
YP2002CN 2003-05-24
  • 打赏
  • 举报
回复
我是初學.
window.open('returnunitname1.asp?spellcoding='+UnitSSN1+"&Citycode="+Citycode+"&ProvinceCode="+ProvinceCode,'register','left=180,top=255,width=250,height=380,status=no,toolbars=no,menubars=no,scrollbars=auto,resize=no');
是你開的新窗口吧..我想所有聯繫人的組織應該在這裡實現吧.
這裡也需要自己重新組織窗口
xhping801216 2003-05-24
  • 打赏
  • 举报
回复
大家都不在吗?怎么还没有人回答我的问题呢

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧