当java中分页页数太多如何判断隐藏
展开全部
</head>
<style>
.otable{width:400px;background-color:blue;}
.otable td{background-color:white;text-align:center;}
.otable label{text-decoration:underline;color:blue;cursor:pointer;}
.frist{display:none}
</style>
<body>
<%
fenYeService fy = new fenYeService();
int pageNum = 5;
fy.setPageNum(pageNum);
int pageCount = fy.pageCount();
int pageNow = 1;
fy.pageFen(pageNow);
if(request.getParameter("pageNow") != null){
pageNow = Integer.parseInt(request.getParameter("pageNow"));
}
ArrayList<emp> list = fy.pageFen(pageNow);
%>
<table class="otable">
<tr>
<td>序号</td>
<td>编号</td>
<td>姓名</td>
<td>部门</td>
<td>工资</td>
</tr>
<%for(emp emp : list){ %>
<tr>
<td><%=emp.getRn() %></td>
<td><%=emp.getEmpno() %></td>
<td><%=emp.getEname() %></td>
<td><%=emp.getDname() %></td>
<td><%=emp.getSal() %></td>
</tr>
<%} %>
<tr>
<td colspan="5">
<form action="MyJsp.jsp" method="post" id="oform">
<input type="hidden" id="hid_pageNow" name="pageNow"/>
</form>
<label id="frist" class="second" onclick="jumpPage(1),hide()">首页</label>
<label id="frist1" onclick="jumpPage(<%=pageNow-1 <=1 ? 1:pageNow-1 %>)">上一页</label>
<%for(int i=1;i<=pageCount;i++){%>
<label onclick="jumpPage(<%=i %>)"><%=i %></label>
<%} %>
<label onclick="jumpPage(<%=pageNow+1 >=pageCount ? pageCount:pageNow+1 %>)">下一页</label>
<label onclick="jumpPage(<%=pageCount %>)">尾页</label>
<input type="text" style="width:30px" id="go"/><input type="button" onclick="goPage()" value="GO"/>
</td>
</tr>
</table>
<script type="text/javascript">
function jumpPage(vPage){
var oform = document.getElementById("oform");
var hid_pageNow = document.getElementById("hid_pageNow");
hid_pageNow.value = vPage;
oform.submit();
};
function goPage(){
var go = document.getElementById("go");
if(isNaN(go.value)){
return;
}else if(go.value < 1 || go.value > <%=pageCount %>){
alert("已经是最后一页");
return;
}else{
jumpPage(go.value);
}
};
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |