<%@ page import="wangzhan.Pd_zhengce" %> <%@ page import="wangzhan.Thesql" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="utf-8" /> <title>科技政策查询系统</title> <link rel="stylesheet" href="css/page.css" /> <script type="text/javascript" src="js/jquery.min.js" ></script> <script type="text/javascript" src="js/index.js" ></script> <script type="text/javascript" src="page.js"></script> <style type="text/css"> #idData {text-align: center;} a{text-decoration: none;} </style> </head> <% String name=request.getParameter("name"); String document=request.getParameter("document"); String organ=request.getParameter("organ"); int len; Pd_zhengce[] pddsall=null; Thesql thesql; if(name==null){name="";} if(document==null){document="";} if(organ==null){organ="";} thesql=new Thesql(); pddsall=thesql.policy_DimQuery(name,document,organ); len= pddsall.length; %> <body onl oad="goPage(1,10);"> <div class="left"> <div class="bigTitle">科技政策查询系统</div> <div class="lines"> <div onclick="pageClick(this)" class="active"><img src="img/icon-1.png" />科技文档管理</div> <div onclick="pageClick(this)"><img src="img/icon-2.png" />系统设置</div> </div> </div> <div class="top"> <div class="leftTiyle" id="flTitle">科技文档管理</div> <div align="center" style="font-weight:bolder;font-size:40px"><img style="width:40px" src="LOGO.png"> <font color="blue">科技政策查询系统</font></div> <div class="thisUser"></div> </div> <div class="content"> <form action="chaxun.jsp" method="get"> <table style="width:100%;height:100%" border="1"> <tr> <td colspan=2 style="height:12%;font-size:30px" align="center"> 政策名称 <input type="text" size="10px" style="height:35px" name="name"> 发文编号 <input type="text" size="10px" style="height:35px" name="document"> 发文机构 <input type="text" size="10px" style="height:35px" name="organ"> 全文检索 <input type="text" size="10px" style="height:35px" name=""> <button id="select" style="width:70px;height:30px;background-color:rgb(200, 241, 248);color:rgb(255,255,255)">查询</button> </td> </tr> <tr> <td> <table id="idData" width="100%" height="100%" border=1 style="font-size:18px;" rules=rows cellspacing=1> <%for(int i=0;i<len;i++) { if(i%9==0){%> <tr><td style="height:12%;width:600px">政策名称 </td> <td style="height:12%;width:14%"> 发文机构 </td> <td style="height:12%;width:13%"> 颁布日期 </td> <td style="height:12%;width:13%"> 政策分类 </td> <td style="height:12%;width:30%"> 操作</td></tr> <%} %> <tr><td style="height:68px;width:364px"><div class="Titlename" style="width:450px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;"><%out.print(pddsall[i].name); %>;</div> </td> <td style="width:14%"><div style="width:150px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;"> <%out.print(pddsall[i].organ); %> </div></td> <td style="width:13%"> <%out.print(pddsall[i].pubdata); %> </td> <td style="width:13%"> <%out.print(pddsall[i].form); %> </td> <td style="width:30%"> <a href="">查看</a></td></tr> <%} %> </table> <tr> <td colspan=2 style="height:20%;"> <table width="100%" align="center" > <tr><td style="font-size:14px;"><div id="barcon" name="barcon"></div></td></tr> </table> <script type="text/javascript"> let titles=document.querySelectorAll('.Titlename'); for(let titlle of titles){ titlle.title=titlle.innerHTML; } /** * 分页函数 * pno--页数 * psize--每页显示记录数 * 分页部分是从真实数据行开始,因而存在加减某个常数,以确定真正的记录数 * 纯js分页实质是数据行全部加载,通过是否显示属性完成分页功能 **/ function goPage(pno,psize){ var itable = document.getElementById("idData"); var num = itable.rows.length;//表格所有行数(所有记录数) console.log(num); var totalPage = 0;//总页数 var pageSize = psize;//每页显示行数 //总共分几页 if(num/pageSize > parseInt(num/pageSize)){ totalPage=parseInt(num/pageSize)+1; }else{ totalPage=parseInt(num/pageSize); } var currentPage = pno;//当前页数 var startRow = (currentPage - 1) * pageSize+1;//开始显示的行 31 var endRow = currentPage * pageSize;//结束显示的行 40 endRow = (endRow > num)? num : endRow; 40 console.log(endRow); //遍历显示数据实现分页 for(var i=1;i<(num+1);i++){ var irow = itable.rows[i-1]; if(i>=startRow && i<=endRow){ irow.style.display = "block"; }else{ irow.style.display = "none"; } } var pageEnd = document.getElementById("pageEnd"); var tempStr = "共"+num+"条记录 分"+totalPage+"页 当前第"+currentPage+"页"; if(currentPage>1){ tempStr += "<a href=\"#\" onClick=\"goPage("+(1)+","+psize+")\">首页</a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\"><上一页</a>" }else{ tempStr += "首页"; tempStr += "<上一页"; } if(currentPage>3){ tempStr += "..<a href=\"#\" onClick=\"goPage("+(currentPage-3)+","+psize+")\">"+(currentPage-3)+"</a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-2)+","+psize+")\">"+(currentPage-2)+"</a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\">"+(currentPage-1)+"</a>"; } tempStr += currentPage; if(currentPage<totalPage-3){ tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">"+(currentPage+1)+"</a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+2)+","+psize+")\">"+(currentPage+2)+"</a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+3)+","+psize+")\">"+(currentPage+3)+"</a>.."; } if(currentPage<totalPage){ tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">下一页></a>"; tempStr += "<a href=\"#\" onClick=\"goPage("+(totalPage)+","+psize+")\">尾页</a>"; }else{ tempStr += "下一页>"; tempStr += "尾页"; } document.getElementById("barcon").innerHTML = tempStr; } </script> </td> </tr> </table></form> </div> </body> </html>
标签:总结,pageSize,每日,var,num,tempStr,4.20,currentPage,endRow From: https://www.cnblogs.com/louwangshayu/p/17338482.html