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

HTML/XHTML教程
Web浏览器模式的选择机制
XHTML+CSS建站如何调用样式表
HTML5和CSS3新的WEB标准和浏览器支持
HTML代码:网页头部代码全清楚
网页制作:HTML代码编写的30条技巧
HTML教程:link标记的rel属性
网页设计参考:firefox的默认样式
网页设计初学者必看的30个网页制作秘笈
网页制作推荐使用的XHTML标记
网页HTML代码讲解:有序列表和无序列表
IE8开发人员工具的菜单讲解
提高用户体验与新窗口打开网页的关系
解决IE支持HTML5的问题
了解如何减少 reflow 次数
平面设计理论:创造视觉冲击力作品
网页HTML 有序列表ol 和无序列表 ul
HTML Frameset 例子代码
让输入框关闭自动完成(AutoComplete)功能
IE支持HTML5的解决方法
基础 HTML之目录问题(相对路径和绝对路径区别)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 53 ::
收藏到网摘: 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>