html:
这里的下拉列表数据从若依字典里取值
<li>
<input type="hidden" class="form-control" name="channelsList" id="channelsList" >
渠道:
<select name="channels" id="channels" th:with="dictList=${@dict.getType('talent_channel')}" class="selectpicker" title="全部" multiple data-live-search="true" data-selected-text-format="count > 2">
<option th:each="dict : ${dictList}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
</select>
</li>
<li style="float: right;padding-right: 60px;">
<a class="btn btn-primary btn-rounded btn-sm" onclick="doSubmit(),$.table.search()"><i class="fa fa-search"></i> 搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset(),doReset()"><i class="fa fa-refresh"></i> 重置</a>
</li>
function doSubmit(){
var str=[];
$("#channels option:selected").each(function () {
str.push($(this).val());// 收集选中项
})
$("#channelsList").val(str);//后端通过获取表单数据channelsList获取多选内容(字符串或数组接收)
}
function doReset() {
$("#channels").selectpicker('refresh');//重置下拉框
}