asp实现动态级联菜单的代码
ASP #菜单2012-05-12 10:59
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>
相关文章
- ASP上传防止图片木马上传的方法 2012/05/12
- asp数字或者字符排序的函数 2012/05/11
- ASP采集HTML内容常用代码 2012/05/11
- ASP防止刷新的功能实现方法 2012/05/11
- ASP把UTF8转换GB2312国标码的函数 2012/05/11
- asp小偷:获取微软安全更新列表 2012/05/11
- ASP去前后空格函数trim,ltrim,rtrim 2012/05/11
- ASP获取ACCESS数据库表名和结构的代码 2012/05/11
- asp过滤HTML标签的函数 2012/05/11
- ASP在线备份与恢复sqlserver数据库 2012/05/11