formSelects-v4.js 基于Layui的多选解决方案
在线 :https://hnzzmsf.github.io/layui-formSelects/docs/index.html
API : https://hnzzmsf.github.io/example/example_v4.html
***** 请先查看API方法 *****
上代码
<form id="form" action="${base}/show.action" method="post">
<div class="formselect">
<div style="float: right;">
<a href="javascript:void(0)" class="layui-btn layui-btn-normal" onclick="doSearch()">
搜索
</a>
</div>
<div style="width: 55%;">
<div <#-- -->style="margin-bottom: 20px;">
<select name="city" xm-select="selectId" xm-select-skin="default">
<#list data.ds2 as record>
<option value="${record.FIELD}" <#if '${record.FIELD}'=='${args.FIELD}'>selected="selected"</#if>>${record.FIELD_NAME}</option>
</#list>
</select>
</div>
<div style="margin-bottom: 15px;">
<input type="text" name="title" id="title" placeholder="请输入标题" autocomplete="off" class="layui-input h_search"
value="${args.title}">
</div>
</div>
</div>
</form>
<link href="${base}/util/dist/formSelects-v4.css" rel="stylesheet" />
<script type="text/javascript" src="${base}/util/dist/formSelects-v4.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
var str = '${args.selectarry}';
var strarr = str.split(",")
formSelects.value('selectId',strarr);
});
//初始化搜索
formSelects.render('selectId');
function doSearch(){
var packJson = formSelects.value('selectId')
var valarry = formSelects.value('selectId', 'val')
var title = $("#title").val();
var str = '<div id="clearfix_input">';
str += '<input type="hidden" id="selectarry" name="selectarry" value="'+valarry+'">';
str += '</div>'
$(".clearfix").after(str);
$.ajax({
type : 'POST',
url : get_web_url()+"/edit_doSearch.action?code=column_list",
data : {"json":JSON.stringify(packJson),"value":title},
success:function(){
$("#form").submit();
}
})
}
</script>