您的位置:首页 > Web前端 > JavaScript

jsp页面中c标签 运用

2016-06-04 14:43 288 查看
   jsp页面中c标签 forEach、forTokens  when choose if 与 input 【text,radio】select的综合运用

 <1> html代码

<div style="display: ${empty mapList ? "none":""}" id="TestForEach">
<div>
<ul style="margin-left: 100px"><li class="active" style="list-style: none;"><b style="font-size: 18px">显示text或select</b></li></ul>
<div >
<c:if test="${not empty mapList}">
<c:forEach var="map" items="${mapList}">
<c:forEach items="${map}" var="map" >
<c:if test="${not empty list}">
<c:forEach var="list" items="${list}">
<input id="map" type="hidden" value="${list.mapId}"/>
<c:if test="${map.key eq list.mapId}">
<ul class="nav nav-tabs">
<li>${list.name}   </li>
<c:choose>
<c:when test="${fn:contains(list.afterValue,',')}">
<select id="${list.mapId}">
<c:forTokens items="${list.afterValue}" delims="," var="afterValue">
<c:choose>
<c:when test="${afterValue eq map.value}">
<li><option value="${afterValue}" selected="selected">${afterValue}</li>
</c:when>
<c:otherwise>
<li><option value="${afterValue}">${afterValue}</li>
</c:otherwise>
</c:choose>
</c:forTokens>
</select>
</c:when>
<c:otherwise>
<li><input id="${list.mapId}" type="text" data="show" value="${map.value}"/></li>
</c:otherwise>
</c:choose>
</ul>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>
</c:if>
</div>
</div>
<div style="display: ${empty mapList ? "none":""}" id="TestForTokens">
<ul><li class="active" style="list-style: none;"><b style="font-size: 18px">显示radio</b></li></ul>
<c:if test="${not empty mapList}">
<c:forEach var="map" items="${mapList}">
<c:forEach var="map" items="${map}">
<c:if test="${not empty list}">
<c:forEach var="list" items="${list}" varStatus="count">
<input id="map" type="hidden" value="${list.mapId}"/>
<c:if test="${map.key == list.mapId}">
<ul class="nav nav-tabs">
<li>${list.name}    </li>
<c:if test="${not empty list.afterValue}">
<c:forTokens items="${list.afterValue}" delims="," var="afterValue">
<c:choose>
<c:when  test="${map.value eq afterValue}">
<li><input id="${list.mapId}" type="radio" sel="sel" name="${count.index}" value="${afterValue}" checked="checked">${afterValue}  </li>
</c:when>
<c:otherwise>
<li><input id="${list.mapId}" type="radio" name="${count.index}" sel="sel" value="${afterValue}">${afterValue}  </li>
</c:otherwise>
</c:choose>
</c:forTokens>
</c:if>
</ul>
</c:if>
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>
</c:if>
</div>
</div>


  <2>在js中获取标签中的值

function getValue(){
var Input = $("#TestForEach input[data='show']").map(function(){
return $(this).attr("id")+"="+$(this).val();
}).get().join("|");
var Select = $("#TestForEach select").map(function(){
return $(this).attr("id")+"="+$(this).val();
}).get().join("|");
alert(Input+"|"+Select);
var radio=$("#TestForTokens :radio[checked='checked']").map(function(){
return $(this).attr("id")+"="+$(this).val();
}).get().join("|");
alert(radio);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jsp