默认选中效果的几种实现方式

1、默认选中单选框

(1)第一种实现方式: 

 <select name="level" class="form-control">
	<%for(int i=9;i>0;i--){
	   request.setAttribute("temi", i);
       %>
	     <option value="<%=i%>"<c:if test="${temi==scase.level}">selected="selected" 
         </c:if>><%=i%></option> 
        <%} %>
 </select>

效果预览:

(2)第二种实现方式:

 <select name="level" class="form-control">
   <c:forEach var="i" begin="1" end="9">
	 <option value="${i}"<c:if test="${i==article.level}">selected="selected"</c:if>>
      ${i}</option>
   </c:forEach>
 </select>

效果预览:

(3)第三种实现方式:

 <select name="price_rmb" class="form-control">
	<option value="50 万以下" ${house.price_rmb=="50 万以下"?"selected":""}>50万以下</option>
	 <option value="50-100万" ${house.price_rmb=="50-100万"?"selected":""}>50-100万</option>
	 <option value="100万以上" ${house.price_rmb=="200万以上"?"selected":""}>800万以上 
         </option>
</select>

效果预览:

2、默认选中多选框

<ul class="dowebok">
	<li><input type="checkbox" value="住宅" name="types" <%=house.getTypes().indexOf("住宅")!=-1?"checked":"" %> data-labelauty="住宅"></li>
	<li><input type="checkbox" value="花园洋房" name="types" <%=house.getTypes().indexOf("花园洋房")!=-1?"checked":"" %>  data-labelauty="花园洋房"></li>
	<li><input type="checkbox" value="别墅"  name="types" <%=house.getTypes().indexOf("别墅")!=-1?"checked":"" %>  data-labelauty="别墅"></li>
	<li><input type="checkbox" value="公寓"  name="types" <%=house.getTypes().indexOf("公寓")!=-1?"checked":"" %>  data-labelauty="公寓"></li>
	<li><input type="checkbox" value="其它"  name="types" <%=house.getTypes().indexOf("其它")!=-1?"checked":"" %>  data-labelauty="其它"></li>
</ul>

效果预览:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值