| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:[求助]联动菜单的改错
只看楼主 加入收藏
jtj123456
Rank: 1
等 级:新手上路
帖 子:60
专家分:0
注 册:2007-7-18
收藏
 问题点数:0 回复次数:0 
[求助]联动菜单的改错

代码如下:<!--#include file="conn1.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<script language ="javascript" >
subclasss = new Array();
<%
dim rs,sql,i
sql = "select * from Class_Table"
set rs = conn.execute(sql)
i = 0
do while not rs.eof
Set rc = Conn.Execute("select * from subclass where Classid=" & rs("ID"))

do while not rc.eof
%>
subclasss[<%=i%>] =new Array("<%=rs("Class")%>","<%=rc("Subclass")%>");
<%i = i + 1
rc.movenext
loop
rc.close
set rc = nothing

rs.movenext
loop

rs.close
set rs = nothing
%>

function changeselect(selvalue){
var selvalue = selvalue;
var i;
document.form1.subclass.length = 0 ;
document.form1.subclass.options[document.form1.subclass.length] = new Option("请选择","");
for (i = 0 ;i <subclasss.length;i++){
if(subclasss[i][0]==selvalue){
document.form1.subclass.options[document.form1.subclass.length] = new Option(subclasss[i][2],subclasss[i][1]);
}
}
}

document.form1.subclass.options[document.form1.subclass.length] = new Option("请选择","");

</script>
<body >

<div align="center">
<form method="POST" action="" name="form1">
<table border="0" cellpadding="0" style="border-collapse: collapse" width="100%" height="59">
<tr>
<td width="67" height="30" ><b><font size="2">地区</font></b></td>
<td height="30" bgcolor="#D4D0C8"><select size="1" name="class" onchange ="changeselect(document.form1.class.options[document.form1.class.selectedIndex].value)">
<%=DbCombox()%></select></td>
</tr>
<tr>
<td width="67" height="30"><b><font size="2">城市</font></b></td>
<td height="30"><select size="1" name="subclass">
</select></td>
</tr>
</table>
</form>
</div>

</body>

</html>
<%
function DbCombox()
dim rs,sql,msg
sql = "select * from Class_Table"
set rs = conn.execute(sql)
while not rs.eof
msg = msg & "<option value=""" & rs("Class") & """>" & rs("Class") & "</option>"
rs.movenext
wend
rs.close
set rs = nothing
DbCombox = msg
End function
%>

说明:从两个表中读数据
表一:Class_Table:
ID Class

表二:subclass:
Subid Subclass Classid(就是第一个表的ID)

[此贴子已经被作者于2007-8-1 9:28:33编辑过]

搜索更多相关主题的帖子: 菜单 改错 
2007-08-01 09:26
快速回复:[求助]联动菜单的改错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051108 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved