网上用的比较多的asp级联菜单效果代码
程序员文章站
2023-01-24 22:48:01
复制代码 代码如下:
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<meta name="generator" content="microsoft frontpage 4.0">
<meta name="progid" content="frontpage.editor.document">
<title>new page 1</title>
</head>
<body>
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from shiinfo order by id asc"
rs.open sql,conn,1,1
%>
<script language="javascript">
var onecount;
onecount=0;
subcat = new array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new array("<%= trim(rs("shiname"))%>","<%= trim(rs("shengcode"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form1.cid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.cid.options[document.form1.cid.length] = new option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<script language="javascript">
<!--
function checkform()
{
document.form1.txtcontent.value=document.form1.doc_html.value;
return true
}
//-->
</script>
<form name=form1 onsubmit="check()">
省份 <%
sql = "select * from shenginfo"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加省份。"
response.end
else
%>
<select name="sid" onchange="changelocation(document.form1.sid.options[document.form1.sid.selectedindex].value)" ><%
do while not rs.eof
%><option selected value="<%=trim(rs("id"))%>"><%=trim(rs("shengname"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
城市:<select name="cid">
<option selected value="">==请选城市==</option>
</select>
</form>
</body>
</html>
复制代码 代码如下:
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<meta name="generator" content="microsoft frontpage 4.0">
<meta name="progid" content="frontpage.editor.document">
<title>new page 1</title>
</head>
<body>
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from shiinfo order by id asc"
rs.open sql,conn,1,1
%>
<script language="javascript">
var onecount;
onecount=0;
subcat = new array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new array("<%= trim(rs("shiname"))%>","<%= trim(rs("shengcode"))%>","<%= trim(rs("id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form1.cid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form1.cid.options[document.form1.cid.length] = new option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<script language="javascript">
<!--
function checkform()
{
document.form1.txtcontent.value=document.form1.doc_html.value;
return true
}
//-->
</script>
<form name=form1 onsubmit="check()">
省份 <%
sql = "select * from shenginfo"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加省份。"
response.end
else
%>
<select name="sid" onchange="changelocation(document.form1.sid.options[document.form1.sid.selectedindex].value)" ><%
do while not rs.eof
%><option selected value="<%=trim(rs("id"))%>"><%=trim(rs("shengname"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
城市:<select name="cid">
<option selected value="">==请选城市==</option>
</select>
</form>
</body>
</html>
上一篇: ASP动态级联菜单实现代码
下一篇: ASP 无限级分类实现