1、第一个下拉框代码
请选择数据资源
selected#if>>${entity.alias!}
#if>
#list>
selected#if>>${entity.alias!}
#if>
#list>
selected#if>>${entity.alias!}
#if>
#list>
2、第二个下拉框代码
selected#if>>${entity.id} - ${entity.name}
#list>
3、后台js代码(url 参数整理)
bindEvents:function(){
var self = this, dom = self.element;
$('select[name="copyfrom"]', dom).change(function(event){
self.params.copyfrom = $(this).val();
var url = self.formatParams(self.params);
window.location.href = "cekasp_article.htm" + url;
});
$('select[name="cid"]', dom).change(function(event){
self.params.cid = $(this).val();
var url = self.formatParams(self.params);
window.location.href = "cekasp_article.htm" + url;
});
}
formatParams:function(params){
var self = this;
var url = "";
for(var param in params){
if(params[param]){
url += param + "=" + params[param] + "&";
}
}
if(url.length > 0){
url = "?" + url.substring(0,url.length-1);
}
return url;
}
4、后台java部分代码(接收参数,然后过滤器根据参数得到想要的结果)
String categoryId = request.optString("cid");
if (!ValidateUtil.isNull(categoryId)) {
// 加载栏目信息
JSONObject jsonCategory = toJSONObject(adminService.loadById(CekaspCategory.class, categoryId));
response.put("category", jsonCategory);
param.addFilter("id", FilterType.IN, articleIdList, 1);
}
String copyfrom = request.optString("copyfrom");
if (!ValidateUtil.isNull(copyfrom)) {
param.addFilter("copyfrom", FilterType.EQUALS, copyfrom);
}
List articleList = adminService.list(CekaspArticle.class,param);
以上这篇bootstrap实现多个下拉框同时搜索的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。