zoukankan      html  css  js  c++  java
  • 基于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>
  • 相关阅读:
    微信公众号开发第三课 实现简单微信文本通讯
    微信公众号开发第二课 百度BAE搭建和数据库使用
    微信公众号开发第一课 预备知识和申请权限账号
    joomla3.1安装不通过Magic Quotes GPC解决方法
    获取汉字拼音的简便方法
    C#快速学习笔记(译)续一
    C#快速学习笔记(译)
    Xcode中如何集成Unity
    【ios开发】iOS App测试方案
    【IOS开发】SimPholders的使用
  • 原文地址:https://www.cnblogs.com/superfeeling/p/13276853.html
Copyright © 2011-2022 走看看