ASP联动菜单
<!--#includefile="conn.asp"--><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN...
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script language="javascript" src="js/class_jl.js"></script>
</head>
<body>
<form name="form1" method="post" action="?">
<%set tjrs=Conn.Execute("select tj from config where id in(1)")
tj=tjrs("tj")
for t=1 to tj+1%>
<SELECT NAME="s<%=t%>" ID="s<%=t%>" >
<OPTION selected ></OPTION>
</SELECT>
<% next %>
</form>
</body>
<script language="javascript">
var array=new Array();
<%
sql="select * from classmag order by classid"
set rs=conn.execute(sql)
i=0
do while not rs.eof
%>
array[<%=i%>]=new Array("<%=rs("classid")%>","<%=rs("syjid")%>","<%=rs("classname")%>"); //数据格式 ID,父级ID,名称
<%
rs.movenext
i=i+1
loop
rs.close
%>
var liandong=new CLASS_LIANDONG_YAO(array)
<%for t=0 to tj
if t=0 then%>
liandong.firstSelectChange("0","s<%=t+1%>");
liandong.firstSelectChange("0","s<%=t+1%>");
liandong.firstSelectChange("0","s<%=t+1%>");
<% Else %>
liandong.subSelectChange("s<%=t%>","s<%=t+1%>");
<% End If
next %>
</script>
</html>
<% for t=1 to tj+1
response.Write request("s"&t)&"<br>"
next%>
联动菜单,选择后再选时恢复不到初始值. 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script language="javascript" src="js/class_jl.js"></script>
</head>
<body>
<form name="form1" method="post" action="?">
<%set tjrs=Conn.Execute("select tj from config where id in(1)")
tj=tjrs("tj")
for t=1 to tj+1%>
<SELECT NAME="s<%=t%>" ID="s<%=t%>" >
<OPTION selected ></OPTION>
</SELECT>
<% next %>
</form>
</body>
<script language="javascript">
var array=new Array();
<%
sql="select * from classmag order by classid"
set rs=conn.execute(sql)
i=0
do while not rs.eof
%>
array[<%=i%>]=new Array("<%=rs("classid")%>","<%=rs("syjid")%>","<%=rs("classname")%>"); //数据格式 ID,父级ID,名称
<%
rs.movenext
i=i+1
loop
rs.close
%>
var liandong=new CLASS_LIANDONG_YAO(array)
<%for t=0 to tj
if t=0 then%>
liandong.firstSelectChange("0","s<%=t+1%>");
liandong.firstSelectChange("0","s<%=t+1%>");
liandong.firstSelectChange("0","s<%=t+1%>");
<% Else %>
liandong.subSelectChange("s<%=t%>","s<%=t+1%>");
<% End If
next %>
</script>
</html>
<% for t=1 to tj+1
response.Write request("s"&t)&"<br>"
next%>
联动菜单,选择后再选时恢复不到初始值. 展开
2个回答
展开全部
asp数据库版二级联动下拉菜单
<script language = "JavaScript">
subcat=new Array();
<%
Dim i
i=0
set rs2=server.createobject("adodb.recordset")
sqltext="select * from [shopxp_stype]"
rs2.open sqltext,conn,1,1
do while not rs2.eof
%>
subcat[<%=i%>]=new Array("<%=rs2("shopxpse_name")%>","<%=rs2("shopxpbe_id")%>","<%=rs2("shopxpse_id")%>");
<%
i=i+1
rs2.movenext
loop
rs2.close
%>
function changelocation(locationid)
...{
document.myform.shopxpse_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i <subcat.length; i++)
...{
if (subcat[i][1] == locationid)
...{ //这句不是很理解
document.myform.shopxpse_id.options[document.myform.shopxpse_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<body>
<form name="myform" method="post" action="adproductshopxp_do.asp" OnSubmit="return checkkk()" >
<table width="90%" border="0" cellpadding="0" cellspacing="5" bgcolor="#F1F3F5">
<tr >
<td width="30%" align="right">选择商品的分类:</td>
<td width="70%">
大类:
<select name="shopxpbe_id" size="1" id="shopxpbe_id" onChange="changelocation(document.myform.shopxpbe_id.options[document.myform.shopxpbe_id.selectedIndex].value)">
<option selected value="0">请选择大类</option>
<%sql="select shopxpbe_id,shopxpbe_name from shopxp_btype"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof%>
<option value="<%=rs(0)%>"><%=rs(1)%></option>
<%rs.movenext
loop
rs.close%>
</select>
小类:
<select name="shopxpse_id">
<option selected value="0">请选择小类</option>
</select> </td>
</tr>
备注:数据库结构:
shopxp_btype表:shopxpbe_id,shopxpbe_name
shopxp_stype表:shopxpse_id,shopxpse_name,shopxpbe_id
<script language = "JavaScript">
subcat=new Array();
<%
Dim i
i=0
set rs2=server.createobject("adodb.recordset")
sqltext="select * from [shopxp_stype]"
rs2.open sqltext,conn,1,1
do while not rs2.eof
%>
subcat[<%=i%>]=new Array("<%=rs2("shopxpse_name")%>","<%=rs2("shopxpbe_id")%>","<%=rs2("shopxpse_id")%>");
<%
i=i+1
rs2.movenext
loop
rs2.close
%>
function changelocation(locationid)
...{
document.myform.shopxpse_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i <subcat.length; i++)
...{
if (subcat[i][1] == locationid)
...{ //这句不是很理解
document.myform.shopxpse_id.options[document.myform.shopxpse_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<body>
<form name="myform" method="post" action="adproductshopxp_do.asp" OnSubmit="return checkkk()" >
<table width="90%" border="0" cellpadding="0" cellspacing="5" bgcolor="#F1F3F5">
<tr >
<td width="30%" align="right">选择商品的分类:</td>
<td width="70%">
大类:
<select name="shopxpbe_id" size="1" id="shopxpbe_id" onChange="changelocation(document.myform.shopxpbe_id.options[document.myform.shopxpbe_id.selectedIndex].value)">
<option selected value="0">请选择大类</option>
<%sql="select shopxpbe_id,shopxpbe_name from shopxp_btype"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof%>
<option value="<%=rs(0)%>"><%=rs(1)%></option>
<%rs.movenext
loop
rs.close%>
</select>
小类:
<select name="shopxpse_id">
<option selected value="0">请选择小类</option>
</select> </td>
</tr>
备注:数据库结构:
shopxp_btype表:shopxpbe_id,shopxpbe_name
shopxp_stype表:shopxpse_id,shopxpse_name,shopxpbe_id
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询