表格翻頁的實作方式很多,以下以js為例為大家詳細介紹下表格翻頁效果的具體實作。 複製程式碼 程式碼如下: 表格翻頁-- -www.jb51.net <BR>body, td{ <BR>font-size: 9pt; <BR>} <BR>a:link { <BR>color: #FF00000 ; <BR>} <BR>a:visited { <BR>color: #FF0000; <BR>} <BR>a:hover { <BR>color: #006600; <BR>} <BR> <BR><!-- <BR>var record = 4;//每頁顯示多少筆記錄<BR>var count = 24;//記錄總數<BR>var pageTotal = ((count record-1)/record)|0;//總頁數<BR>var pagenum = 1;//將要顯示的頁碼<br><br><BR>Cookie = { <BR>Set : function (){ <BR>var name = arguments[0], value = escape(arguments[1]), days = 365, path = "/"; <BR>if(arguments.length > 2) days = arguments <BR>if(arguments.length > 2) days = arguments [2]; <BR>if(arguments.length > 3) path = arguments[3]; <BR>with(new Date()){ <BR>setDate(getDate() days); <BR>days=toUTCString (); <BR>} <BR>document.cookie = "{0}={1};expires={2};path={3}".format(name, value, days, path); <BR> }, <BR>Get : function (){ <BR>var returnValue=document.cookie.match(new RegExp("[b^;]?" arguments[0] "=([^;]*)(?= ;|b|$)","i")); <BR>return returnValue?unescape(returnValue[1]):returnValue; <BR>} <BR>} <BR>String.prototype.format = function() { <BR>var tmpStr = this; <BR>var iLen = arguments.length; <BR>for(var i=0;i<iLen;i ){ <BR>tmpStr = tmpStr.replace(new RegExp("\ {" i "\}", "g"), arguments[i]); <BR>} <BR>return tmpStr; <BR>} <BR>function setPagenum(){//整理Cookie <BR>pagenum = Cookie.Get("pagenum"); <BR>if(pagenum=="" || pagenum<1){ <BR>pagenum=1; <BR>} <br>} <br><br>setPagenum() ; <br><BR>//重新整理目前頁碼,如果頁面小於1,則賦值為1,如果大於總頁數,則等於總頁數<br>coordinatePagenum(pagenum); <br><BR>/ /依照目前要顯示的頁碼取得當前面裡第一筆記錄的號碼<br>var pageBegin = (record*(pagenum-1) 1)|0; <br><BR>//依照目前要顯示的頁碼取得前面裡最後一筆記錄的號碼<br>var pageEnd = record*pagenum; <br><BR>function showhiddenRecord(pagenum){ <BR>number.innerHTML=pagenum; <BR>if(pagenum<=1) { <BR>theFirstPage.innerHTML="第一頁"; <BR>thePrePage.innerHTML="上一頁"; <BR>}else{ <BR>theFirstPage.innerHTML="<a href="javascript:firstPage( )">第一頁"; <BR>thePrePage.innerHTML="<a href="javascript:prePage()">上一頁"; <BR>} <BR>if( pagenum>=pageTotal){ <BR>theNextPage.innerHTML="下一頁"; <BR>theLastPage.innerHTML="最後一頁"; <BR>}else{ <BR>theNextPage.innerHTML="<a href== "javascript:nextPage()">下一頁"; <BR>theLastPage.innerHTML="<a href="javascript:lastPage()">最後一頁"; <BR>} <BR>document.getElementById('goto').value=pagenum; <BR>//根據目前要顯示的頁碼取得當前面裡第一筆記錄的號碼<br>pageBegin = (record*(pagenum-1) 1)|0; <br><BR>//根據目前要顯示的頁碼取得當前面裡最後一筆記錄的號碼<BR>pageEnd = record*pagenum; <BR>for(var i=1;i<= count;i ){ <BR>if(i>=pageBegin && i<=pageEnd){ <BR>mytable.rows[i].style.display=""; <BR>}else{ <BR>mytable.rows [i].style.display="none"; <BR>} <BR>} <BR>Cookie.Set("pagenum", pagenum); <br>} <br><BR>function firstPage(){ <BR>pagenum=1; <BR>showhiddenRecord(pagenum); <br>} <br><BR>function lastPage(){ <BR>showhiddenRecord(pageTotal); <br>} <br>showhiddenRecord(pageTotal); <BR>} <BR>} <BR>整理目前頁碼,如果頁面小於1,則賦值為1,如果大於總頁數,則等於總頁數<BR>function coordinatePagenum(num){ <BR>if(num<1){ <BR>num=" 1"; <BR>}else if(num>pageTotal){ <br>num=pageTotal; <br>} <BR>} <BR><BR>function prePage(){ <BR>pagenum--; <br>function prePage(){ <br>pagenum--; <BR> >coordinatePagenum(pagenum); <BR>showhiddenRecord(pagenum); <BR>} <BR><br>function nextPage(){ <br>pagenum ; <BR>coordinatePagenum(pagenum); <BR>} <BR><🎜>function gotoPage(num){ <🎜>coordinatePagenum(pagenum); <🎜>showhiddenRecord(num); <🎜>}<BR>//--> <BR> <中央> 共 6 页現在の前第 1 页 第一页 上一页 下一页 最後の一页 转到第 <オプション値=1>1オプション> 2 3 4 5 6 页 标题 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24