码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2020-07-10 00:18:29      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:public   ntb   ext   styles   text   orm   pca   line   code   

<!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的城市三级联动

标签:public   ntb   ext   styles   text   orm   pca   line   code   

原文地址:https://www.cnblogs.com/superfeeling/p/13276853.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!