JQuery 根据表单条件无刷新查询分页有错误

年少莫轻狂 发布于 2013/01/30 13:08
阅读 776
收藏 0

【DevOps必读】产品经理与程序员之间如何破局?>>>

我自己写了一个JQuery根据表单条件进行无刷新分页查询,页面加载的时候默认查询全部可以显示出查询的信息,但是点击表头那个排序或是填写查询条件然后再点击查询整个页面就会显示成这样。。。

求高手指点一下哪出错了

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
	<title>法规文件管理</title>
	<script type="text/javascript" src="../resource/jquery/jquery.js"></script>
    <link href="../resource/global/css/style.css" rel="stylesheet" type="text/css"/> 
    <link href="../resource/global/css/global.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../resource/calendar/calendar_zip.js"></script>
    <style type="text/css"> @import url("../resource/calendar/skins/calendar-win2k-cold-1.css"); </style>
 	
 	<script type="text/javascript">
 		var page=null;
	    	$(document).ready(function(){
				var url = null;
				query(url);	  
				
				$("#begain").live('click',function(){
					var url = "law_queryLawfile.action?date="+new Date()+"&pageNow="+page.beginPage+"&pageSize="+page.pageSize;
					query(url);
				});  	
				$("#upper").live('click',function(){
					var url = "law_queryLawfile.action?date="+new Date()+"&pageNow="+page.upperPage+"&pageSize="+page.pageSize;
					query(url);
				});
				$("#next").live('click',function(){
					var url = "law_queryLawfile.action?date="+new Date()+"&pageNow="+page.nextPage+"&pageSize="+page.pageSize;
					query(url);
				});
				$("#end").live('click',function(){
					var url = "law_queryLawfile.action?date="+new Date()+"&pageNow="+page.endPage+"&pageSize="+page.pageSize;
					query(url);
				});
				$("#jump").live('click',function(){
					var url = "law_queryLawfile.action?date="+new Date()+"&pageNow="+$("#jump").val()+"&pageSize="+page.pageSize;
					query(url);
				});
			
				
				//=====================动态排序的实现Start=============================
				$("#d1").toggle(
					function(){
					  	$("#sortname").val("id");
					  	$("#sortorder").val("desc");
					  	$("#d1").html("序号︾");
					  	$("#sform").submit(function(){
					  		query(url);	  
					  	});
					  	query(url);
					},function(){
						$("#sortname").val("id");
						$("#sortorder").val("asc");
						$("#d1").html("序号︽");
						$("#sform").submit(function(){
					  		query(url);	  
					  	});
				});
				$("#d2").toggle(
					function(){
					  	$("#sortname").val("lawname");
					  	$("#sortorder").val("desc");
					  	$("#d2").html("规章名称︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("lawname");
						$("#sortorder").val("desc");
						$("#d2").html("规章名称︽");
						$("#sform").submit();
				});
				$("#d3").toggle(
					function(){
					  	$("#sortname").val("filenumber");
					  	$("#sortorder").val("desc");
					  	$("#d3").html("文号︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("filenumber");
						$("#sortorder").val("asc");
						$("#d3").html("文号︽");
						$("#sform").submit();
				});
				$("#d4").toggle(
					function(){
					  	$("#sortname").val("orgAward");
					  	$("#sortorder").val("desc");
					  	$("#d4").html("颁发机关︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("orgAward");
						$("#sortorder").val("asc");
						$("#d4").html("颁发机关︽");
						$("#sform").submit();
				});
				$("#d5").toggle(
					function(){
					  	$("#sortname").val("DAward");
					  	$("#sortorder").val("desc");
					  	$("#d5").html("颁发时间︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("DAward");
						$("#sortorder").val("asc");
						$("#d5").html("颁发时间︽");
						$("#sform").submit();
				});
				$("#d6").toggle(
					function(){
					  	$("#sortname").val("hostDept");
					  	$("#sortorder").val("desc");
					  	$("#d6").html("主办单位︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("hostDept");
						$("#sortorder").val("asc");
						$("#d6").html("主办单位︽");
						$("#sform").submit();
				});
				$("#d7").toggle(
					function(){
					  	$("#sortname").val("remark");
					  	$("#sortorder").val("desc");
					  	$("#d7").html("备注信息︾");
					  	$("#sform").submit();
					},function(){
						$("#sortname").val("remark");
						$("#sortorder").val("asc");
						$("#d7").html("备注信息︽");
						$("#sform").submit();
				});
			//=====================动态排序的实现End=============================

	    	});
	    	
	    	
	     function modifyLawfile(id){
	     	alert("asd");
	     	var url = "login_preModifyLawfile.action?id="+id;
	      	window.location.href=url;
	      	//window.open(url,"信息维护",'height=500, width=800, top=150, left=300, toolbar=no, menubar=no, scrollbars=yes,resizable=no,location=no, status=no');
	     }
	           
	        
	        function thisdata(data){
	    			page= data;
	    	}
	    		
	        
	        function query(url){
	        		if(url==null){
	        			url = "law_queryLawfile.action?date="+new Date();
	        		}
		    		$.ajax({
		    			url:url,
		    			type:"post",
		    			dataType:"json",
		    			contentType:"application/x-www-form-urlencoded; charset=UTF-8",
		    			success:function(data){
		    				thisdata(data);
		    				showInfo(data);
		    				showPage(data);
		    				if(data.pageNow=="1"){
		    					$("#begain,#upper").attr({'disabled':'disabled'});
		    				}
		    				if(data.pageNow==page.nextPage){
		    					$("#next").attr({'disabled':'disabled'});
		    					if(data.nextPage==data.endPage){
		    						$("#end").attr({'disabled':'disabled'});
		    					}
		    				}
		    				if(data.pageNow==data.pageNumber){
		    					$("#next,#end").attr({'disabled':'disabled'});
		    				}
		    			}
		    		});
	    			
	    		}
	    		
	    		
	    		
	    		function showInfo(data){
	    			var str = "";
					var list = data.dateList;
					for ( var i = 0; i < list.length; i++) {
								str =str+ "<tr> <td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+i+1+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].lawname+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].filenumber+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].orgAward+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].DAward+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].hostDept+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>"+list[i].remark+
								" </td><td height='18' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'><a href = '#' onclick='modifyLawfile("+list[i].id+")'"+
								"'>维护</a></td> </tr>";
							}
						$("#tbody1").html(str);
	    		}
	    		
	    		
	    		function showPage(page){
	    				var htmlStr = "";
							htmlStr = htmlStr+"<tr><th colspan='9' align='right' bgcolor='#f3ffe3'> "+
							"第"+page.pageNow+"/"+page.pageNumber+"页"+"&nbsp;&nbsp;总记录:"+page.pageCount+
							"&nbsp;&nbsp;转到第<input class='SureKam_Input_0' onkeydown='javascript:window.event.cancelBubble = true;"+
							"if (event.keyCode == 13) {gotopage();}' type='text' id='jump' name='gopageno' size='2' maxlength='10' value='1'/>页&nbsp;&nbsp;"+
							"<a href='#' id='jump' style=' text-decoration:none; '>跳转&nbsp;&nbsp;</a>&nbsp;"+
							"<a id='begain' href='#' style=' text-decoration:none; '>首页</a> "+
							"<a id='upper' href='#' style=' text-decoration:none; '>上一页</a> "+
							"<a id='next' href='#'style=' text-decoration:none; '>下一页</a> "+
							"<a id='end' href='#'style=' text-decoration:none; '>尾页</a> ";
							
							$("#tbody2").html(htmlStr);
	    		}
	        
	        function gotopage(){
					var url = "login_queryUsers.action?date="+new Date()+"&pageNow="+$("#jump").val()+"&pageSize="+page.pageSize;
					query(url);
	        }
 	</script>
 	
	</head>
	<body>
		<form id="sform" action="law_queryLawfile.action" method="post">
		  <table width="98%" border="0" align="center"	cellpadding="1"  cellspacing="1" class="form_table"> 
		     <thead> 
		       <tr> 
		            <th colspan="6">查询</th> 
		       </tr> 
		     </thead> 
		     </table>
		     <table width="80%" border="0" align="center"	>
		        <tr> 
		        	 <th width="10%" align="right">规章名称:</th> 
		            <td width="20%" >
		            	<input type="hidden" id="sortname" name="sortname">
		            	<input type="hidden" id="sortorder" name="sortorder">
		            	<input type="text" name="lawname" maxlength="50">
		            </td> 
		            <th width="10%" align="right">文号:</th> 
		            <td width="20%">
		            	<input type="text" name="filenumber" maxlength="50" >
		            </td> 
		            <th width="10%" align="right" >主办单位:</th> 
		            <td width="20%">
		            	<input type="text" name="hostDept" maxlength="50" >
		            </td>
		        </tr>
		         <tr> 
		        	 <th width="10%" align="right">添加时间:</th> 
		            <td width="20%" colspan="3">
			            <input type="text" name="d_add1" maxlength="50"  readonly>
			            <img src="../resource/calendar/img.gif" align="middle"  id="f_trigger_c" style="cursor: pointer;"/>
			            <script type="text/javascript">
							Calendar.advMode("d_add1","f_trigger_c");
						</script>
			            
			            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至:&nbsp;&nbsp;&nbsp;&nbsp;
			            <input type="text" name="d_add2" maxlength="50" readonly>
			             <img src="../resource/calendar/img.gif" align="middle"  id="f_trigger_d" style="cursor: pointer;"/>
			            <script type="text/javascript">
							Calendar.advMode("d_add2","f_trigger_d");
						</script>
		    		</td> 
		            <th width="10%" align="right" >颁发机关:</th> 
		            <td width="20%"><input type="text" name="orgAward" maxlength="50" ></td>
		        </tr> 
		       </table>
			 
		    <!--=========================================-->
		   <table width="100%" border="0" cellspacing="0" cellpadding="1"> 
				<tr>
		           <td > 
						<p  align="center" style="width:100%"> 
						  <input type="submit" name="button" value="查询 " class="btn4" /> 
						   <input type="reset" name="button" value="重置 " class="btn4" /> 
						  <input type="button" name="button" value="添加新规章" class="btn4" onclick="javascript:window.location.href='law_preAddLawfile.action'"/> 
						</p> 
					</td>
		        </tr> 
			</table>
		</form>
	   <!--===================报表统计======================-->
	    <table width="99%" align="center"  border="1" cellspacing="0" cellpadding="0" >
	      <tr> 
            <td height="33" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><jsp:include page="JfreeChartByhostDept.jsp"/></div></td> 
            <td height="33" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><jsp:include page="JfreeChartByOrgAward.jsp"/></div></td> 
            <td height="33"  bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><jsp:include page="JfreeChartByAwardTime.jsp"/></div></td>
	      </tr>
	   </table>
	   <!--===================结果列表 ======================-->
	    <table width="99%" border="0" align="center"	cellpadding="1"  cellspacing="1" class="form_table">
	      <thead>
		      <tr> 
		            <th width="5%" height="24" align="center"><div id="d1" align="center" class="STYLE2 STYLE1" style="cursor: pointer;">序号︽</div></th> 
		            <th width="10%" height="24" align="center"><div id="d2" align="center" class="STYLE2 STYLE1" style="cursor: pointer;">规章名称︽</div></th>
		            <th width="10%" height="24" align="center"><div id="d3" align="center" class="STYLE2 STYLE1" style="cursor: pointer;">文号︽</div></th>
		            <th width="10%" height="24" align="center"><div id="d4" align="center" class="STYLE2" style="cursor: pointer;">颁发机关︽</div></th> 
		            <th width="10%" height="24" align="center"><div id="d5" align="center" class="STYLE2" style="cursor: pointer;">颁发时间︽</div></th> 
		            <th width="15%" height="24" align="center"><div id="d6" align="center" class="STYLE2" style="cursor: pointer;">主办单位︽</div></th>
		            <th width="15%" height="24" align="center"><div id="d7" align="center" class="STYLE2" style="cursor: pointer;">备注信息︽</div></th>
		            <th width="15%" height="24" align="center"><div align="center" class="STYLE2">操作</div></th>  
		        </tr>
	        </thead> 
	        <tbody id="tbody1"></tbody>
	   </table>
	   <table width="100%" border="0" cellspacing="0" cellpadding="1">
	   		<tbody id="tbody2"></tbody>
	   </table>
	     
	   
	     
  </body>
</html>
加载中
0
th小米粥
th小米粥
我表示头晕。截取关键点吧。
0
刘文博
刘文博
去网上下载一个吧,不要自己写撒
0
dedenj
dedenj
jqgird。。
返回顶部
顶部