layui select多选下拉显示 以及回显

时间:2024-03-09 12:08:31
<input type="hidden" id="hiddensheshi" name="hiddensheshi" value="${sysEntertainment.sheshi}">
<div class="layui-form-item layui-form-text" >
		    <label class="layui-form-label"><span style="color:red;">*        
                    </span>多选</label>
		    <div class="layui-form" style="margin-left:130px;">
				<select name="sheshi" xm-select="selectId" id="sheshi">
				     <option value="">--请选择--</option> 
				</select>
		    </div>
</div>        

  

var diclistsheshi = ${diclistsheshi}; //后台用model存的List<Map<String,String>>
        if(diclistsheshi != "" && diclistsheshi != null ){
                //在下拉框显示选项
                var arr = [];
                var lis = $("#hiddensheshi").val(); 
                for(var i = 0;i<diclistsheshi.length;i++){
                    var arrStr = {name:diclistsheshi[i].dicname,value:diclistsheshi[i].dicnum};
                    arr.push(arrStr);
                }
                formSelects.data(\'selectId\', \'local\', {
                    arr: arr
                });
                //渲染之前选中的(业务编辑功能用的到)
                //取出之前已经选中的编码 1101,1103,1105,1107
                var lis = $("#hiddensheshi").val(); 
                var lisarr = lis.split(",");
                 formSelects.value(\'selectId\',lisarr,true);
        }else{
            hint("获得酒店设施失败", true);
        }