这个功能是前不久在项目中遇到的。。
功能描述:
我界面设置选择的时间,一个星期 中的几天,这一天中的上午下午或全天。。这星期几用checkbox勾选出来。后面并带这是对应的下拉框显示全天上午或下午。。。
额。。差不多就这意思。俺表达能力不行。。等会看图理解吧。。嘿嘿。
<form action="setStopTime_saveStopTime.html" name="WForm" οnsubmit="return checkWeek();">
<s:hidden name="stopTime.runType" value="2"/>
<div id="block2" style="padding:20px 50px;">
<%
List<Integer> wDateList = (List<Integer>)request.getAttribute("wDateList");//复选框所需要 的值
List<Integer> wTimeTypeList =(List<Integer>)request.getAttribute("wTimeTypeList");//下拉框所需要 的值
List<String> week= (List<String>)request.getAttribute("week");//一个星期集合
%>
<%for (int i=0;i<7 ;i++){%>
<!-- 复选框在此 -->
<%
if(wDateList.contains(i)){
int index = 0;
for(int j =0; j<wDateList.size();j++){
if(i==wDateList.get(j)){
index = j;
}
}
%>
<span class="week">
<input type="checkbox" name="wDate" value="<%=i%>"checked="checked"/><%=week.get(i) %>
<%int w = wTimeTypeList.get(index); %>
<%request.setAttribute("w",w);%>
<!-- 星期几 -->
<select name="wTime">
<c:choose>
<c:when test="${w ==1}">
<option value="1" selected="selected">全天</option>
<option value="2">上午</option>
<option value="3">下午</option>
</c:when>
<c:when test="${w ==2}">
<option value="1">全天</option>
<option value="2" selected="selected">上午</option>
<option value="3">下午</option>
</c:when>
<c:when test="${w ==3}">
<option value="1">全天</option>
<option value="2">上午</option>
<option value="3" selected="selected">下午</option>
</c:when>
</c:choose>
</select><br/>
</span>
<%
} else {
%>
<span class="week">
<input type="checkbox" name="wDate" value="<%=i %>"/><%=week.get(i) %>
<select name="wTime">
<option value="1">全天</option>
<option value="2">上午</option>
<option value="3">下午</option>
</select><br/>
</span>
<%}} %>
<input type="submit" value="保存" />
</div>
</form>
这里也可以使用对象来取值的。。额。可我脑子一时没转过弯。。当时就想到了这个集合了。。