在线等待:急!急!急!

bitzhw 2002-03-28 09:18:23
我在一个页面中有二个<select>,想根据第一个<select>的数据(页面初装是从数据库读取的数据),查询数据库,得到的数据在第二个<select>中显示,???
...全文
58 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bitzhw 2002-03-29
  • 打赏
  • 举报
回复
执行下面代码:从SQL探测器中发现IIS 不断查询SQL服务器。而使脚本执行时间超出设置时间!问题在那???请指点

读分支机构表 的两字段到两数组里
<%
connstr=application("oa_connectionstring")
set conn=server.CreateObject ("adodb.connection")
set rs=server.CreateObject ("adodb.recordset")
conn.Open connstr
dim sql
sql="select distinct 市县 from 分支机构表 "
rs.Open sql,connstr,1 ,1
f=rs.RecordCount
Response.Write("f is ="&f)
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
</HEAD>

<script language="javascript">

var a_muni=new Array();
a_muni[0]="请选择";
a_muni[1]="";
<%
temp_i=2
municount=0
dim munipart()
redim munipart(rs.recordcount-1)
'response.write"<p>before code is ok"
while not rs.eof
municount=municount+1
munipart(municount-1)=rs("市县")
' response.write("<p>munipart="&munipart(municount-1))
%>
a_muni[<%=temp_i%>]="<%=rs("市县")%>";
a_muni[<%=temp_i+1%>]="<%=rs("市县")%>";
<%
temp_i=temp_i+2
rs.movenext
wend
rs.close
%>

var village=new array()
<% for temp_i=0 to temp_i/2-1 %>
village[<%=temp_i%> =new array();
<% next %>
village[0][0]="请选择";
village[0][1]="";
<%
temp_i=1
while temp_i<=municount
%>
village[<%=temp_i%>][0]="请选择";
village[<%=temp_i%>][0]="";
<%
response.write("munipart[temp_i]"&munipart(temp_i))
sql="select 企业_id ,乡镇 from 分支机构表 where 市县='"&munipart(temp_i)&"'"
set rs=conn.execute(sql)
temp_j=2
while not rs.eof
%>
village[<%=temp_i%>][<%=temp_j%>]="<%=rs("乡镇")%>";
village[<%=temp_i%>][<%=temp_j+1%>]="<%=rs("企业_id")%>";
<%
temp_j=temp_j+2
rs.movenext
wend
temp_j=tem_j+1
wend
%>


</script>
weidegong 2002-03-28
  • 打赏
  • 举报
回复
代码?
bitzhw 2002-03-28
  • 打赏
  • 举报
回复
我用showModalDialog打开第一个页面,用表单提交后,虽然选择的是
target="_self" ,但是它还是打开一个新页面????怎么办!

weidegong 2002-03-28
  • 打赏
  • 举报
回复
实现方法

一、因为这种设计数据量一般不多
在页面初装时,利用ASP/JSP程序读取数据库,将两个<select>的数据全部读取出来,并对上述aListValue进行赋值即可实现要求。

二、数据量较大时
读取第一个<select>的数据,选择了其中一个选项之后,从数据库读取数据重新生成第二个<select>,这个没有什么难的吧?
weidegong 2002-03-28
  • 打赏
  • 举报
回复
实现传递代码如下:

---------------------------------------
<script language="javascript">
var aListValue = new Array(2);
aListValue["a"] = new Array("1","2");
aListValue["b"] = new Array("3");

var nCurIndex = null;

function setupList()
{
if (nCurIndex != document.frmtest.name1.selectedIndex)
{
nCurIndex = document.frmtest.name1.selectedIndex;

var sValue = document.frmtest.name1.options[nCurIndex].value;

var i;
//remove existing list
for (i=document.frmtest.name2.options.length-1; i >=0 ; i--)
document.frmtest.name2.options.remove(i);

for (i=0; i < aListValue[sValue].length;i++)
{
var opt = new Option(aListValue[sValue][i],aListValue[sValue][i]);
document.frmtest.name2.options.add(opt);
}

}

}
</script>

<body onload="setupList()">
<form name="frmtest" action="" method="post">
List1: <select name="name1" onchange="setupList()">
<option value="a">a</option>
<option value="b">b</option>
</select><br>
List2:
<select name="name2">
</select><br>
</form>
</body>

slowpoke 2002-03-28
  • 打赏
  • 举报
回复
很簡單, 找一找精華貼, 裡面好像有
孟子E章 2002-03-28
  • 打赏
  • 举报
回复
搜索一下,或到asp搜索,已经很多了

87,996

社区成员

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

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