1. 程式人生 > >layui下拉聯動

layui下拉聯動

IT spa UNC func _id 下拉 park span path

layui下寫入監聽,

searchPname 是第一個下拉框
searchParkingname 是第二個下拉框
            form.on(‘select(searchPname)‘, function(data){
                $.getJSON(apiCtxPath + "/comuser/vipuser/userVipByParkingarea?parkingsvrId="+data.value, function(data){
                    var optionstring = "";
                    console.log(data);
                    
for (var i = 0; i < data.list.length; i++) { optionstring += "<option value=\"" + data.list[i].columns.u_parkingarea_id + "\" >" + data.list[i].columns.parkingname + "</option>"; } /* $.each(data.data, function(i,item){ });
*/ $("#searchParkingname").html(‘<option value=""></option>‘ + optionstring); form.render(‘select‘); //這個很重要 }); });

下面是第二個下拉框html部分

                    <div class="form-group">
                          <label class="control-label" for
="ordercode">停車場</label> <select id="searchParkingname" name="searchParkingname" lay-filter="searchParkingname" lay-verify="required" lay-search=""> <option value="">直接選擇或搜索選擇</option> <option value=""></option> </select> </div>

layui下拉聯動