二级联动菜单——ASP+数据库版

<!--#include file="../include/buyok_shop_30_conn.asp"-->
<script language = "javascript">
var j;
j=0;
goaler = new Array();
<%set rs=conn.execute("select * from newsclass where classid<>0 order by ID")'二级菜单
if rs.eof then%>
goaler[0] = new Array("无分类","","");
<%else
i=0
do while not rs.eof%>
goaler[<%=i%>] = new Array("<%=rs("minclassname")%>","<%=rs("classid")%>","<%=rs("ID")%>");//classid为一级的ID,ID为自己的ID
<%rs.movenext
i=i+1
loop
end if
rs.close
%>
j=<%=i%>;

function changelocation(locationid)
{
document.addnews.SmallClassID.length = 0;

var locationid=locationid;
var i;
for (i=0;i < j; i++)
{
if (goaler[i][1] == locationid)
{
document.addnews.SmallClassID.options[document.addnews.SmallClassID.length] = new Option(goaler[i][0], goaler[i][2]);
}
}

}
</script>

<form method="post" name="addnews" action="">
<select name="BigClassID" onChange="changelocation(document.addnews.BigClassID.options[document.addnews.BigClassID.selectedIndex].value)" size="1">
<%set rs=conn.execute("select * from newsclass where classid=0 order by ID")'一级
if rs.eof then%>
<option selected value="">无一级分类</option>
<%else%>
<option selected value="">请选择一级分类</option>
<%do while not rs.eof%>
<option value="<%=rs("ID")%>"><%=rs("classname")%></option>
<%rs.movenext
loop
end if%>
</select>
<select name="SmallClassID">
<option selected value="">未指定一级分类</option>
</select>
<input type="submit" name="goaler" value="提交">
</form>


<%'测试取值
if request("goaler")<>"" then
response.write "ID="&request("ID")&"<BR>ID="&request("ID")
end if%>

 


 

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/haibo0668/article/details/51565716
个人分类: ASP技术
上一篇JS和ASP混合使用案例
下一篇光标清除文本框的初始值
想对作者说点什么? 我来说一句

asp二级联动 html二级联动

2009年06月17日 2KB 下载

没有更多推荐了,返回首页

关闭
关闭