asp+access中如何联动多级菜单?
感谢回答,我说的联动菜单不是指导航条那种菜单,而是指比如在一个菜单里选择北京(第一个菜单的值同样也是从数据库中读取的),第二个菜单就自动从数据库读取海淀、石景山等区县,这...
感谢回答,我说的联动菜单不是指导航条那种菜单,而是指比如在一个菜单里选择北京(第一个菜单的值同样也是从数据库中读取的),第二个菜单就自动从数据库读取海淀、石景山等区县,这种联动菜单。
展开
1个回答
展开全部
多少级呢?一般最多就三级。再往下循环就不那么美观了。
<script language = "JavaScript">
var onecount;
var threecount;
onecount=0;
threecount=0
subcat3=new Array();
subcat3[0] = new Array("111","582","642");
subcat3[1] = new Array("1111","578","614");
threecount=2;
subcat = new Array();
subcat[0] = new Array("","0","610");
subcat[1] = new Array("助油","58","584");
subcat[2] = new Array("项链","56","576");
onecount=3;
function changelocation(locationid)
{
document.myform.shopxpse_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.shopxpse_id.options[document.myform.shopxpse_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
changelocation3(document.myform.shopxpse_id.options[document.myform.shopxpse_id.selectedIndex].value)
}
function changelocation3(locationid)
{
document.myform.xclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < threecount; i++)
{
if (subcat3[i][1] == locationid)
{
document.myform.xclassid.options[document.myform.xclassid.length] = new Option(subcat3[i][0], subcat3[i][2]);
}
}
}
//-->
</script>
<body>
<form name="myform" method="post" action="sshopxpaddpt.asp?action=add" OnSubmit="return checkkk()" >
<table width="96%" border="0" cellpadding="0" cellspacing="5" bgcolor="#F1F3F5">
<tr >
<td width="23%" align="right">选择商品的分类:</td>
<td width="77%">
大类:
<select name="shopxpbe_id" size="1" id="shopxpbe_id" onChange="changelocation(document.myform.shopxpbe_id.options[document.myform.shopxpbe_id.selectedIndex].value)">
<option value="64">系统配件</option>
<option value="63">机身配件</option>
<option value="71">电子电器</option>
<option value="56">功能附件</option>
<option value="55">排屑器</option>
<option value="57">油冷机</option>
<option value="80">光栅尺</option>
<option value="82">第四轴</option>
<option value="58">刀库</option>
<option value="81">更多/其它商品</option>
</select>
小类:
<select name="shopxpse_id" size="1" id="shopxpse_id" onChange="changelocation3(document.myform.shopxpse_id.options[document.myform.shopxpse_id.selectedIndex].value)">
<option value="568">主轴</option>
<option value="569">丝杆</option>
</select>
三级分类:
<select name="xclassid">
<option>暂时没有分类</option>
<option value="584">主轴</option>
</select>
</td>
</tr> </table>
<script language = "JavaScript">
var onecount;
var threecount;
onecount=0;
threecount=0
subcat3=new Array();
subcat3[0] = new Array("111","582","642");
subcat3[1] = new Array("1111","578","614");
threecount=2;
subcat = new Array();
subcat[0] = new Array("","0","610");
subcat[1] = new Array("助油","58","584");
subcat[2] = new Array("项链","56","576");
onecount=3;
function changelocation(locationid)
{
document.myform.shopxpse_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.shopxpse_id.options[document.myform.shopxpse_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
changelocation3(document.myform.shopxpse_id.options[document.myform.shopxpse_id.selectedIndex].value)
}
function changelocation3(locationid)
{
document.myform.xclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < threecount; i++)
{
if (subcat3[i][1] == locationid)
{
document.myform.xclassid.options[document.myform.xclassid.length] = new Option(subcat3[i][0], subcat3[i][2]);
}
}
}
//-->
</script>
<body>
<form name="myform" method="post" action="sshopxpaddpt.asp?action=add" OnSubmit="return checkkk()" >
<table width="96%" border="0" cellpadding="0" cellspacing="5" bgcolor="#F1F3F5">
<tr >
<td width="23%" align="right">选择商品的分类:</td>
<td width="77%">
大类:
<select name="shopxpbe_id" size="1" id="shopxpbe_id" onChange="changelocation(document.myform.shopxpbe_id.options[document.myform.shopxpbe_id.selectedIndex].value)">
<option value="64">系统配件</option>
<option value="63">机身配件</option>
<option value="71">电子电器</option>
<option value="56">功能附件</option>
<option value="55">排屑器</option>
<option value="57">油冷机</option>
<option value="80">光栅尺</option>
<option value="82">第四轴</option>
<option value="58">刀库</option>
<option value="81">更多/其它商品</option>
</select>
小类:
<select name="shopxpse_id" size="1" id="shopxpse_id" onChange="changelocation3(document.myform.shopxpse_id.options[document.myform.shopxpse_id.selectedIndex].value)">
<option value="568">主轴</option>
<option value="569">丝杆</option>
</select>
三级分类:
<select name="xclassid">
<option>暂时没有分类</option>
<option value="584">主轴</option>
</select>
</td>
</tr> </table>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询