基于PCASClass.js和layui.js的城市三级联动

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="../Public/js/layui/css/layui.css" />
        <title></title>
    </head>

    <body>
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">城市</label>
                <div class="layui-input-inline">
                    <select id="province" name="org_province" lay-filter="org_province">
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select id="city" name="org_city" lay-filter="org_city">
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select id="area" name="org_area" lay-filter="org_area">
                    </select>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="../Public/js/layui/layui.js"></script>
        <script type="text/javascript" src="../Public/js/PCASClass.js"></script>
    </body>
    <script>
        var mypcas = new PCAS("org_province", "org_city", "org_area", "请选择省份", "请选择城市", "请选择地区");
        layui.use([form], function() {
            var form = layui.form;
            var province;
            form.on(select(org_province), function(data) {
                province = data.value;
                //不清除的话,layui高版本会出现选项重复
                document.getElementById("province").innerHTML="";
                document.getElementById("city").innerHTML="";
                document.getElementById("area").innerHTML="";
                var mypcas = new PCAS("org_province", "org_city", "org_area", province, "请选择城市", "请选择地区");
                form.render(select);
            });
            form.on(select(org_city), function(data) {
                //不清除的话,layui高版本会出现选项重复
                document.getElementById("province").innerHTML="";
                document.getElementById("city").innerHTML="";
                document.getElementById("area").innerHTML="";
                var mypcas = new PCAS("org_province", "org_city", "org_area", province, data.value, "请选择地区");
                form.render(select);
            });
        });
    </script>

</html>

 

基于PCASClass.js和layui.js的城市三级联动

上一篇:爬虫-urllib的使用(2)


下一篇:css 选择器