JS制作简便的三级联合浮动,

复制代码 代码如下:

JS制作轻巧的三级联合浮动,

用javascript制作的二个差不离三级联合浮动,特别简单实用

复制代码 代码如下:
<!DOCTYPE html>
<html>
    <head>
        <meta charset=”utf-8″>
        <title></title>
    </head>
    <body>
        省:
        <select style=”width: 100px;” id=”pre”
onchange=”chg(this);”>
            <option value=”-1″>请选择</option>
        </select>
        市:
        <select style=”width: 100px;” id=”city” onchange=”chg2(this)”
;></select>
        区:
        <select style=”width: 100px;” id=”area”></select>
    </body>
    <script>
         //声明省
        var pres = [“北京”, “上海”, “山东”]; //直接注解Array
         //声明市
        var cities = [
            [“东城”, “昌平”, “海淀”],
            [“浦东”, “高区”],
            [“济南”, “青岛”]
        ];
        var areas = [
                [
                    [“东城1”, “东城2”, “东城3”],
                    [“昌平1”, “昌平2”, “昌平3”],
                    [“海淀1”, “海淀2”, “海淀3”]
                ],
                [
                    [“浦东1”, “浦东2”, “浦东3”],
                    [“高区1”, “高区2”, “高区3”]
                ],
                [
                    [“济南1”, “济南2”],
                    [“青岛1”, “青岛2”]
                ]
            ]
            //设置多个省的公家下标
        var pIndex = -1;
        var preEle = document.getElementById(“pre”);
        var cityEle = document.getElementById(“city”);
        var areaEle = document.getElementById(“area”);
         //先设置省的值
        for (var i = 0; i < pres.length; i++) {
            //声明option.<option
value=”pres[i]”>Pres[i]</option>
            var op = new Option(pres[i], i);
            //添加
            preEle.options.add(op);
        }
        function chg(obj) {
            if (obj.value == -1) {
                cityEle.options.length = 0;
                areaEle.options.length = 0;
            }
            //获取值
            var val = obj.value;
            pIndex = obj.value;
            //获取ctiry
            var cs = cities[val];
            //获取暗许区
            var as = areas[val][0];
            //先清空市
            cityEle.options.length = 0;
            areaEle.options.length = 0;
            for (var i = 0; i < cs.length; i++) {
                var op = new Option(cs[i], i);
                cityEle.options.add(op);
            }
            for (var i = 0; i < as.length; i++) {
                var op = new Option(as[i], i);
                areaEle.options.add(op);
            }
        }
        function chg2(obj) {
            var val = obj.selectedIndex;
            var as = areas[pIndex][val];
            areaEle.options.length = 0;
            for (var i = 0; i < as.length; i++) {
                var op = new Option(as[i], i);
                areaEle.options.add(op);
            }
        }
    </script>
</html>

如上所述即是本文的全体内容了,希望我们能够欣赏。

用javascript制作的叁个回顾三级联合浮动,特别轻便实用 复制代码 代码如下:
!DOCTYPE html html head meta charset=”utf-8″ title/t…

<div id=”box”>

上述所述正是本文的全体内容了,希望大家能够喜欢。

                qu.options.add(op);

用javascript制作的一个简易三级联合浮动,极其轻易实用

[“开发区1″,”开发区2″,”开发区3”]

您恐怕感兴趣的文章:

  • javascript深入分析xml实现省市县三级联合浮动的形式
  • javascript读取Xml文件做三个二级联合浮动菜单示例
  • JS+XML
    省份和城市里面包车型大巴联合浮动达成代码
  • js实现的举国省市二级联合浮动下拉摘取菜单完整实例
  • PHP+Mysql+Ajax+JS完毕省市区三级联合浮动
  • JS实多级联合浮动下拉菜单类,轻松实现省市区联合浮动菜单!
  • 最佳用的省市二级联动原生js完成您值得全数
  • jquery+json
    通用三级联动下拉列表
  • javascript贯彻省市区三级联合浮动下拉框菜单
  • js使用xml数据载体实现城市省份二级联合浮动功效

var quArr = [

<!DOCTYPE html>
<html>
    <head>
        <meta charset=”utf-8″>
        <title></title>
    </head>
    <body>
        省:
        <select style=”width: 100px;” id=”pre”
onchange=”chg(this);”>
            <option value=”-1″>请选择</option>
        </select>
        市:
        <select style=”width: 100px;” id=”city” onchange=”chg2(this)”
;></select>
        区:
        <select style=”width: 100px;” id=”area”></select>
    </body>
    <script>
         //声明省
        var pres = [“北京”, “上海”, “山东”]; //直接证明Array
         //声明市
        var cities = [
            [“东城”, “昌平”, “海淀”],
            [“浦东”, “高区”],
            [“济南”, “青岛”]
        ];
        var areas = [
                [
                    [“东城1”, “东城2”, “东城3”],
                    [“昌平1”, “昌平2”, “昌平3”],
                    [“海淀1”, “海淀2”, “海淀3”]
                ],
                [
                    [“浦东1”, “浦东2”, “浦东3”],
                    [“高区1”, “高区2”, “高区3”]
                ],
                [
                    [“济南1”, “济南2”],
                    [“青岛1”, “青岛2”]
                ]
            ]
            //设置多少个省的公物下标
        var pIndex = -1;
        var preEle = document.getElementById(“pre”);
        var cityEle = document.getElementById(“city”);
        var areaEle = document.getElementById(“area”);
         //先设置省的值
        for (var i = 0; i < pres.length; i++) {
            //声明option.<option
value=”pres[i]”>Pres[i]</option>
            var op = new Option(pres[i], i);
            //添加
            preEle.options.add(op);
        }
        function chg(obj) {
            if (obj.value == -1) {
                cityEle.options.length = 0;
                areaEle.options.length = 0;
            }
            //获取值
            var val = obj.value;
            pIndex = obj.value;
            //获取ctiry
            var cs = cities[val];
            //获取暗中同意区
            var as = areas[val][0];
            //先清空市
            cityEle.options.length = 0;
            areaEle.options.length = 0;
            for (var i = 0; i < cs.length; i++) {
                var op = new Option(cs[i], i);
                cityEle.options.add(op);
            }
            for (var i = 0; i < as.length; i++) {
                var op = new Option(as[i], i);
                areaEle.options.add(op);
            }
        }
        function chg2(obj) {
            var val = obj.selectedIndex;
            var as = areas[pIndex][val];
            areaEle.options.length = 0;
            for (var i = 0; i < as.length; i++) {
                var op = new Option(as[i], i);
                areaEle.options.add(op);
            }
        }
    </script>
</html>

[“天水”,”白银”,”兰州”]

}

[

</select>

\["高区1","高区2","高区3"\],

//先设置省的值

</head>

}

            for (var i = 0; i < as.length;
i++) {

*{margin: 0;padding: 0;}

var shi = document.getElementById(“si”);

<style type=”text/css”>

</select>

var s = new
Option(shengArr[i], i);

            }

];

 

var sheng =
document.getElementById(“sh”);

                qu.options.add(op);

            index = obj.value;

要素中有所 <option> 的一个数组

                var op = new
Option(as[i], i);

<script type=”text/javascript”>

                var op = new Option(cs[i], i);

</script>

<head>

            //先清空市和区

 

}

                var op = new
Option(as[i], i);

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图