`

jquery+jstl实际应用

 
阅读更多
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"  %> 
<%@include file="/common/common_lib.jsp"%>
	<!-- js代码区 -->
	<script type="text/javascript" >
	
		//确定
		function confirm(){
			var addHiddenHtmlId='<%=request.getParameter("addHiddenHtmlId")%>';
			var newHtml="";
			var i=addHiddenHtmlId.replace("addHiddenHtmlId_","");
			var j=0;
			//将房表主键赋值给父页面
			$("input[name='housefid']").each(function(){
				if($(this).attr("checked")){
					newHtml+='<input class="'+addHiddenHtmlId+'" type="hidden" name="basicinfo.beforeafterList[0].houseList['+j+'].fid" value="'+$(this).val()+'"" />';
					j++;
				}
			});
			//将样式为addHiddenHtmlId变量的都删除掉
			$("."+addHiddenHtmlId).remove();
			$("#"+addHiddenHtmlId).append(newHtml);
			
			//alert($("#"+addHiddenHtmlId).html())
			closeWindow('getHouseQuery');
		}
		//取消
		function cancel(){
			closeWindow('getHouseQuery');
		}
		//全选
		function allClick(){
			if($("#all").attr("checked")){
				//查找当前行下的checkbox元素,迭代将过滤掉的数据置为未选中
				//$("#house tr").not("#houseTr0").each(function(){
					//if($(this).css("display")=="block"){
						//$(this).find("input[name='housefid']").each(function(){
							//$(this).attr("checked",true);
						//});
					//}
				//});
				$("input[name='housefid']").attr("checked",true); 
			}else{
				$("input[name='housefid']").attr("checked",false); 
			}
		}
		
		//根据幢名称过滤房信息
		function queryByBuildName(buildName)  {
			//alert("buildName:" + buildName);
			
			if (buildName == '') {
				//如果幢名称为空,则table下的所有行都显示
				$("#house tr").each(function(){
					$(this).css("display", "block");
				});
			} else {
				//如果幢名称不唯恐,则table下的除了id为houseTr0不参加迭代,其他都参与,根据幢名称过滤列表
				$("#house tr").not("#houseTr0").each(function(){
					if (buildName == $(".buildNameClass", $(this)).text() ) {
						$(this).css("display", "block");
					} else {
						$(this).css("display", "none");
						//查找当前行下的checkbox元素,迭代将过滤掉的数据置为未选中
						//$(this).find("input[type='checkbox']").each(function(){
							//$(this).attr("checked",false)
						//});
					}
				});
			}
		}
		
		//获取幢名称,形成下拉列表
		$(".buildNameClass").each(function(){
			var buildName=$(this).text();
			var noBuildName=true;
			$("#buildName option").each(function() {
				if($(this).val() == buildName) {
					noBuildName = false;
					return;
				}
			});
			if(noBuildName){
				var opt= "<option value='" + buildName + "'>" + buildName + "</option>";
				$(opt).appendTo($("#buildName"));
			}
		});
	</script>
	<div id="Layer1">
		<div id="Layer2">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
		      <tr>
		        <td class="fontColor1">房屋信息</td>
		      </tr>
      		  <tr>
        		<td>
        			<font class="fontColor2">原证类型:${rightcerttypename} </font>
        			<font class="fontColor2">原证号码:${rightcertnum}</font>
        			<font class="fontColor2">所在幢:
						<select id="buildName" name="buildName" onchange="queryByBuildName(this.value)">
							<option value="">所有</option>
						</select>
					</font>
       			</td>
      		</tr>
      		<tr>
      			<td>
      				<table border="0" cellspacing="1" cellpadding="0" class="listForm" id="house">
						<tr id="houseTr0"  >
							<th style="width:30px;"><input type="checkbox" name="all" id="all" onclick="allClick()"/></th>
							<th>幢名称</th>
							<th>单元名称</th>
							<th>所在层</th>
							<th>房号</th>
							<th>房屋坐落</th>
							<th>总层数</th>
							<th>建筑面积</th>
							<th>设计用途</th>
							<th>房唯一号</th>
						</tr>
						<c:forEach items="${houseList}" var="l">
							<tr id="houseTr_${l.fid}">
								<td><input type="checkbox" name="housefid" value="${l.fid}"/></td>
								<td class="buildNameClass" >${l.buildname}</td>
								<td>${l.unitname}</td>
								<td>${l.floorname}</td>
								<td>${l.doorname}</td>
								<td>${l.sitnumgather}</td>
								<td>${l.totalfloorcounts}</td>
								<td>${l.architarea}</td>
								<td>${l.usagename}</td>
								<td>${l.houseid}</td>
							</tr>
						</c:forEach>
					</table>
      			</td>
      		</tr>
		    <tr>
		       	<td height="45" align="right">
		       		<img src="<%=basePath%>images/icon_bc.jpg" width="47" height="20" onclick="confirm()" />
		       		<img src="<%=basePath%>images/icon01_27.png" width="47" height="20" class="leftWidth1" onclick="cancel()" />
		       	</td>
		    </tr>
    	</table>
		</div>
	</div>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics