asp动态级联菜单代码


JS脚本:
<%
dim rs
dim sql
dim count
dim rs1
dim sql1
sql = "select * from region order by zoneid asc"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("regionname"))%>","<%= trim(rs("zoneid"))%>","<%= trim(rs("regionid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count%>;

function changelocation(zoneid)
{
document.myform.region.length = 0;

var zoneid=zoneid;
var i;
document.myform.region.options[0] = new Option('--地区--','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == zoneid)
{
document.myform.region.options[document.myform.region.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>

表单内容:
<table>
<form>
<tr>
<td>
<span class="STYLE1">*</span> 大区:
<select name="zone" size="1" id="zone" onChange="changelocation(document.myform.zone.options[document.myform.zone.selectedIndex].value)">
<option value=0 selected >请选择</option>
<%

sql1 = "select * from bigzone order by zonename asc"
set rs1 = server.createobject("adodb.recordset")
rs1.open sql1,conn,1,3
%>
<%while not rs1.eof%>
<option value="<%=rs1("zoneid")%>"><%=rs1("zonename")%></option>
<%rs1.movenext
wend
rs1.close
set rs1 = nothing
%>
</select> </td>
<td width="20%"><span class="STYLE1">*</span>地区:
<select name="region" size="1" id="region" >
<option value=0 selected >请选择</option>
</select>
</tr>
</form>
</table>



相关阅读:
Google AJAX Language API开发者参考
Oracle提高SQL执行效率的三种方法
C# 小数位数保留的方法集锦
如何把PHP转成EXE文件
一个简单的自动发送邮件系统(一)
用ASP.NET MVC创建TaskList应用程序
Windows操作系统31招快速修复技巧(中)
Linux操作系统下关于内存查看的详细解析
CSS编程提醒及小技巧整理(25条)
用Asp备份与恢复SQL Server 数据库
mysql时区问题
手把手教你配置Windows2003集群
为指定元素增加样式的js代码
Linux crontab定时执行任务 命令格式与详细例子
快速导航

Copyright © 2016 phpStudy | 皖ICP备18014864号-4