asp动态级联菜单代码
网络编程 2021-07-05 10:58www.168986.cn编程入门
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>
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程