实现根据不同查询条件查询列表的功能,如图:
查询条件要用form提交:
<div class="lead well">
<form name='form1'>
提现类型:<select name="type" size="1" style="width: 10%" id = "WithDrawType" οnchange="WithDrawTypeOnchange()">
<option value ="">请选择</option>
<c:forEach items="${withDrawTypes}" var = "ty">
<option value = "${ty.value}"
<c:if test="${ty.value eq type}">
selected = "selected"
</c:if>> ${ty.description }</option>
</c:forEach>
</select>
<span>
提现渠道: <select name = "channel" size="1" style="width: 10%" id="WithdrawChannel">
<option value ="">请选择</option>
<option value ="1" <c:if test="${1 eq channel }">selected </c:if>>支付宝</option>
<option value ="2" <c:if test="${2 eq channel }">selected </c:if>>微信</option>
</select>
</span>
<label style="width: 20px"></label>
<input type="hidden" value = "${exHandle}" id = "exHandleId"/>
<input class="btn btn-danger" type = "button" value = "查询" οnclick="Search()"/>
</form>
</div>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
js:
$(function() {
WithDrawTypeOnchange();
});
function Search() {
var exHandle = $("#exHandleId").val();
if(exHandle == 'true') {
$("form[name='form1']").attr("action",
"<c:url value='/withdraw/exlist'/>");
}else {
$("form[name='form1']").attr("action",
"<c:url value='/withdraw/waitSpds'/>");
}
$("form[name='form1']").submit();
}
function WithDrawTypeOnchange() {
var type = $("#WithDrawType").find("option:selected").val();
if(type != 0) {
$("#WithdrawChannel").find("option[value='']").attr("selected",true);
$("#WithdrawChannel").attr("disabled",true);
}else {
$("#WithdrawChannel").attr("disabled",false);
}
}
---------------------------------------------------------------------------------------------------------------
后端需要传:
model.addAttribute("type", type);
model.addAttribute("channel", channel);