两级下拉菜单联动
如题,下面的代码您可以完全复制过去然后保存为.html格式就能直接浏览(急,麻烦哪位大哥哥大姐姐帮帮忙,好拉一定给您追加分)代码如下:<!DOCTYPEhtmlPUBLI...
如题,下面的代码您可以完全复制过去 然后保存为.html格式就能直接浏览(急,麻烦哪位大哥哥大姐姐帮帮忙,好拉一定给您追加分)代码如下:
<!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>
</head>
<body>
<form action="" method="post" name="fromno" id="fromno">
<select name="Distinction" id="Distinction">
<option selected value="0">选择类型</option>
<option value="购买">购买</option>
<option value="消耗">消耗</option>
</select>
<select name="purpose" id="purpose">
<option selected value="0">选择途径</option>
<option value="购买卷">购买券</option>
<option value="物换卷">物换券</option>
<option value="兑换卷">兑换券</option>
<option value="卷换物">券换物</option>
<option value="兑换券">兑换券</option>
</select>
</form>
</body>
</html>
******************************************************
当我点购买时,第二个下拉框只显示:购买卷、物换卷、兑换卷
当我点消耗时,第二个下拉框只显示:卷换物、兑换券 展开
<!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>
</head>
<body>
<form action="" method="post" name="fromno" id="fromno">
<select name="Distinction" id="Distinction">
<option selected value="0">选择类型</option>
<option value="购买">购买</option>
<option value="消耗">消耗</option>
</select>
<select name="purpose" id="purpose">
<option selected value="0">选择途径</option>
<option value="购买卷">购买券</option>
<option value="物换卷">物换券</option>
<option value="兑换卷">兑换券</option>
<option value="卷换物">券换物</option>
<option value="兑换券">兑换券</option>
</select>
</form>
</body>
</html>
******************************************************
当我点购买时,第二个下拉框只显示:购买卷、物换卷、兑换卷
当我点消耗时,第二个下拉框只显示:卷换物、兑换券 展开
展开全部
<!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" lang="gb2312">
<head>
<head>
<title> </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
</head>
<body>
<select id="Distinction" name="Distinction" size="1" onchange="Redirect(this.options.selectedIndex)">
<option selected value="0">选择类型</option>
<option value="购买">购买</option>
<option value="消耗">消耗</option>
</select>
<select id="purpose" name="purpose" size="1">
<option value="1">选择类型</option>
</select>
<script type="text/javascript">
<!--
var groups = document.getElementById("Distinction").options.length;
var group = new Array(groups)
for (i = 0; i < groups; i ++)
group[i] = new Array()
group[0][0] = new Option("选择类型","0")
group[1][0] = new Option("购买券","购买券")
group[1][1] = new Option("物换券","物换券")
group[1][2] = new Option("兑换券","兑换券")
group[2][0] = new Option("券换物","券换物")
group[2][1] = new Option("兑换券","兑换券")
var temp = document.getElementById("purpose");
function Redirect(x){
for (m = temp.options.length-1; m > 0; m --)
temp.options[m] = null
for (i = 0; i < group[x].length; i ++){
temp.options[i] = new Option(group[x][i].text,group[x][i].value);
}
temp.options[0].selected = true
}
//-->
</script>
</body>
</html>
做了下。 如果你要新加, 自己看着办吧。
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<head>
<title> </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
</head>
<body>
<select id="Distinction" name="Distinction" size="1" onchange="Redirect(this.options.selectedIndex)">
<option selected value="0">选择类型</option>
<option value="购买">购买</option>
<option value="消耗">消耗</option>
</select>
<select id="purpose" name="purpose" size="1">
<option value="1">选择类型</option>
</select>
<script type="text/javascript">
<!--
var groups = document.getElementById("Distinction").options.length;
var group = new Array(groups)
for (i = 0; i < groups; i ++)
group[i] = new Array()
group[0][0] = new Option("选择类型","0")
group[1][0] = new Option("购买券","购买券")
group[1][1] = new Option("物换券","物换券")
group[1][2] = new Option("兑换券","兑换券")
group[2][0] = new Option("券换物","券换物")
group[2][1] = new Option("兑换券","兑换券")
var temp = document.getElementById("purpose");
function Redirect(x){
for (m = temp.options.length-1; m > 0; m --)
temp.options[m] = null
for (i = 0; i < group[x].length; i ++){
temp.options[i] = new Option(group[x][i].text,group[x][i].value);
}
temp.options[0].selected = true
}
//-->
</script>
</body>
</html>
做了下。 如果你要新加, 自己看着办吧。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询