asp动态级联菜单代码
更新时间:2007年03月21日 00:00:00 作者:
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>
<%
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>
相关文章
asp中Scripting.Dictionary字典对象使用示例
这篇文章主要介绍了asp中Scripting.Dictionary字典对象使用示例,本文包含创建、赋值、遍历、判断KEY等操作,需要的朋友可以参考下2014-08-08asp cookie中文Javascript取得中文cookie
这篇文章主要介绍了asp cookie中文Javascript取得中文cookie,原理就是将中文编码改成UTF-8编码格式,传到前台,再用JS将其解码2014-07-07Asp中Server.ScriptTimeOut属性需要注意的一点分析
Server.ScriptTimeout 这个属性给定Asp脚本执行的最大时间,如果asp程序的运行时间超过了这个属性规定的值,Asp就会报错。2011-06-06如何在 Access 2003 和 Access 2002 中创建 DSN 的连接到 SQLServer 对链接表
如何在 Access 2003 和 Access 2002 中创建 DSN 的连接到 SQLServer 对链接表...2006-10-10asp中response.write(''中文'')或者js中文乱码问题
这篇文章主要介绍了asp中response.write('中文')或者js中文乱码问题,有时候我们需要输出js也会出现乱码,这里给出了几个解决方法,需要的朋友可以参考下2020-03-03
最新评论