<%@ page language="java" pageEncoding="utf-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:if test="${pageView.totalPage gt 1 }"> <!-- 分頁信息 --> 頁碼:${pageView.currentPage}/${pageView.totalPage}頁 每頁顯示:${pageView.pageSize}條 總記錄數:${pageView.recordCount}條 分頁: <a href="javascript:gotoPage(1)">[首頁]</a> <c:if test="${pageView.currentPage gt 1}"> <a href="javascript:gotoPage(${pageView.currentPage - 1})">[上一頁]</a> </c:if> <c:if test="${pageView.currentPage lt pageView.totalPage}"> <a href="javascript:gotoPage(${pageView.currentPage + 1})">[下一頁]</a> </c:if> <a href="javascript:gotoPage(${pageView.totalPage})">[尾頁]</a> <!-- 顯示頁碼 --> <c:forEach begin="${pageView.startPageIndex}" end="${pageView.endPageIndex}" var="pageNum"> <c:if test="${pageNum eq pageView.currentPage}"> <span class="current_page">${pageNum}</span> </c:if> <c:if test="${pageNum ne pageView.currentPage}"> <a href="javascript:gotoPage(${pageNum})">${pageNum}</a> </c:if> </c:forEach> 轉到: <input type="text" id="txtPageNum" size="4" class="input_pagenum"/> <input type="button" onclick="gotoPage(document.getElementById('txtPageNum').value)" value="Go"/> <script type="text/javascript"> /** * 跳轉到指定的頁碼 */ function gotoPage( pageNum ){ if( isNaN(pageNum) ){ // not a number alert("請輸入正確的頁碼"); document.getElementById('txtPageNum').focus(); return false; } if( pageNum < 1 || pageNum > ${pageView.totalPage} ){ alert("請輸入正確的頁碼,范圍為 1-${pageView.totalPage}"); document.getElementById('txtPageNum').focus(); return false; } window.location.href = getPageViewUrl( pageNum ); // getPageViewUrl為在include頁面添加的javscript代碼, // 所以此頁面可以適用于任何分頁信息的顯示。例如下: //function getPageViewUrl( pageNum ){ // return "?method=list&pageNum=" + pageNum; //} } </script> </c:if> |