layui下的下拉框輸入修改


頁面:

                    <input type="text" name="LicenseIdtext" id="LicenseIdtext" class="layui-input" style="position:absolute;z-index:2;width:80%;"  value="" onkeyup="search()"   autocomplete="off">
                    <select type="text" id="LicenseId" lay-filter="LicenseId" autocomplete="off" placeholder="移交單位全稱"  class="layui-select" lay-search>
                        <option value="">請選擇</option>
                    </select>

js:

    //選擇移交單位 賦值給input框
    form.on('select(LicenseId)', function (data) {
        if (data.value != "") {
            $("#LicenseIdtext").val(data.value);
        }        
        $("#LicenseId").next().find("dl").css({
            "display": "none"
                });
                form.render();
                });

            window.search = function () {
                var value = $("#LicenseIdtext").val();
                $("#LicenseId").val(value);
                if (value=="請選擇") {
                    $("#LicenseId").val("");
                }                
                form.render();
                $("#LicenseId").next().find("dl").css({ "display": "block" });
                var dl = $("#LicenseId").next().find("dl").children();
                var j = -1;
                for (var i = 0; i < dl.length; i++) {
                    if (dl[i].innerHTML=="請選擇") {
                        dl[i].style.display = "block";
                        continue;
                    }
                    if(dl[i].innerHTML.indexOf(value) <= -1) {
                        dl[i].style.display = "none";
                        j++;
                    }
                    if (j == dl.length-1) {
                        $("#LicenseId").next().find("dl").css({ "display": "none" });
                    }
                }               

            }

只是根據業務簡單的修改


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM