当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 连动下拉菜单

HTML/XHTML教程
CSS实用教程(二)
CSS 循序渐进(二)字的艺术
CSS 循序渐进(一)画个瓢
CSS语法手册(二)文本属性
CSS语法手册(四)文本填充,边框,边界和位置属性(二)
CSS语法手册(一)字体属性
CSS语法手册(三)文本填充,边框,边界和位置属性(一)
CSS语法手册(五)颜色和背景属性
CSS语法手册(六)分类属性
捷足先登学用CSS:HTML结构化
HTML语言剖析(4)
HTML语言剖析(3)
HTML语言剖析(1)
HTML语言剖析(2)
网页背景设计全攻略(2)
在 CSS 中关于字体处理效果的思考
常见页面元素遮住菜单解决方法
样 式 表 全 接 触(1)
样 式 表 全 接 触(2)
样 式 表 全 接 触(6)

HTML/XHTML教程 中的 连动下拉菜单


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 82 ::
收藏到网摘: n/a

<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script LANGUAGE="javascript">
<!--
var onecount;
onecount=0;
   
subcat = new Array();
subcat[0] = new Array("徐汇区","01","001");
subcat = new Array("嘉定区","01","002");
subcat = new Array("黄浦区","01","003");
subcat = new Array("南昌市","02","004");
subcat = new Array("九江市","02","005");
subcat = new Array("上饶市","02","006");

onecount=6;

function changelocation(locationid)
    {
    document.myform.smalllocation.length = 0;

    var locationid=locationid;
    var i;
    document.myform.smalllocation.options[0] = new Option('====所有地区====','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i] == locationid)
            {
            document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i]);
            }       
        }
       
    }   

//-->
</script>
</head>
<body>
<form name="myform" method="post">
    <select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
        <option value="01" selected>上海</option>
        <option value="02">江西</option>
    </select>
    <select name="smalllocation">
        <option selected value="">==所有地区==</option>
    </select>
</form>
<script LANGUAGE="javascript">
<!--
    changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value);

//-->
</script>
</body>
</html>