html代码
<input type="text" value=" " id="HandoverCompany" class="layui-input" style="position:absolute;z-index:2;"
lay-verify="required" οnkeyup="search()" οnfοcus="search()" autocomplete="off">
<select name="supplier_id" id="hc_select" lay-filter="hc_select" >
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
js代码
form.on('select(hc_select)', function (data) { //选择移交单位 赋值给input框
$("#HandoverCompany").val($(this).html());
$("#hc_select").next().find("dl").css({ "display": "none" });
form.render();
});
window.search = function () {
var value = $("#HandoverCompany").val();
$("#hc_select").val(value);
form.render();
$("#hc_select").next().find("dl").css({ "display": "block" });
var dl = $("#hc_select").next().find("dl").children();
var j = -1;
for (var i = 0; i < dl.length; i++) {
if (dl[i].innerHTML.indexOf(value) <= -1) {
dl[i].style.display = "none";
j++;
}
if (j == dl.length-1) {
$("#hc_select").next().find("dl").css({ "display": "none" });
}
}
}