今天完成了河北科技政策查询的改良
增加了题目左对齐,显示字数一致,当鼠标悬浮在题目时,显示完整题目
按日期排序
点击题目就可以查看内容,取消原先右边的查看按钮
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2023/4/10 Time: 15:20 To change this template use File | Settings | File Templates. --%> <%@ page language= "java" contentType= "text/html; charset=UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <%@ page import="java.sql.*"%> <title>www.科技政策查询</title> <style type=""> td{ max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }</style> <script> /** * 分页函数 * 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 = 11;//每页显示行数 //总共分几页 if(num/pageSize > parseInt(num/pageSize)){ totalPage=parseInt(num/(pageSize-1))+1; }else{ totalPage=parseInt(num/(pageSize-1)); } 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 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<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> <script th:src="@{/layuimini/js/lay-module/echarts/echarts.js}"></script> <script th:src="@{/layuimini/js/lay-module/echarts/wordcloud.js}"></script> <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" /> <script src="https://www.layuicdn.com/layui/layui.js"></script> </head> <body onl oad="goPage(1,10);"> <div style="text-align:center;"> <img src="images/LOGO.png" width="40" height="40" style="margin-right: 10px;"> <span style="font-size: 35px; color:#1571b2;">科技政策查询系统</span> </div> <div style="text-align:center;width:100%;height:65px;float:left; position:relative; display: table-cell;vertical-align: middle; background-color: rgba(232,232,232,0.76) "> <form class="layui-form" action="servlet?method=SelectAll" method="post" align="center" > <p> </p> <div class="layui-form-item"> <div class="layui-inline"> <label class="layui-form-label"> 政策名称: </label> <div class="layui-input-inline"> <input type="text" name="name" class="layui-input"> </div> </div> <div class="layui-inline"> <label class="layui-form-label"> 政策文号: </label> <div class="layui-input-inline"> <input type="text" name="document" class="layui-input"> </div> </div> <div class="layui-inline"> <label class="layui-form-label"> 发文机构: </label> <div class="layui-input-inline"> <input type="text" name="organ" class="layui-input"> </div> </div> <div class="layui-inline"> <div class="layui-input-inline"> <button type="submit" class="layui-btn" lay-submit lay-filter="demo1"style="background-color: #1571b2">查询</button> </div> </div> </div> </form> </div> <div style="float:top" align="center"> <form class="layui-form" action="servlet?method=SelectAll" method="post" align="center" > <table id="idData" border="1px" align="center" class="layui-table"style="table-layout: fixed;word-wrap:break-word;" > <thead> <tr align="center"> <td style="width: 320px">政策名称</td> <td style="width:320px">发文机构</td> <td style="width: 320px">颁布日期</td> <td style="width:320px">政策分类</td> </tr> </thead> <tbody> <c:forEach items="${kc}" var="Policy"> <tr align="center"> <td style="width: 320px" title="${Policy.name}"><a href="servlet1?method1=${Policy.name}"><c:out value="${Policy.name}"></c:out> </td> <td style="width: 320px" title="${Policy.organ}"><c:out value="${Policy.organ}"></c:out></td> <td style="width: 320px" title="${Policy.date}"><c:out value="${Policy.date}"></c:out></td> <td style="width: 320px" title="${Policy.type}"><c:out value="${Policy.type}"></c:out></td> </tr> </c:forEach> </tbody> </table> </form> </div> <table width="100%" align="center"> <tr><td style="text-align:center;"><div id="barcon" name="barcon"></div></td></tr> </table> </body> </html>
标签:总结,分页,pageSize,19,num,tempStr,var,endRow From: https://www.cnblogs.com/liucaizhi/p/17334905.html