<div class="codetitle"> <span><a style="CURSOR: pointer" data="58201" class="copybut" id="copybut58201" onclick="doCopy('code58201')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code58201"> <br> <br> <br> <br><title>表格翻頁 TITLE> <br><style> <BR>body, td{ <BR>font-size: 9pt; <BR>} <BR>a:link { <BR>color: #FF0000; <BR>} <BR> a:visited { <BR>color: #FF0000; <BR>} <BR>a:hover { <BR>color: #006600; <BR>} <BR></style> <br><script language=" JavaScript"> <BR><!-- <BR>var record = 4;//每頁顯示多少筆記錄<BR>var count = 24;//記錄總數<BR>var pageTotal = ((count record-1 )/record)|0;//總頁數<BR>var pagenum = 1;//將要顯示的頁碼<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[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。頁"; <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>showhiddenReop( pagenum); <BR>} <br><br>function lastPage(){ <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>coordinatePagenum(pagenum) <BR>pagenum--; <BR>showhiddenPagenum(pagenum); <br>show pagenum); <br>} <BR><BR>function nextPage(){ <BR>pagenum ; <BR>coordinatePagenum(pagenum); <br>showhiddenRecord(pagenum); <br>} <BR><BR><BR> gotoPage(num){ <🎜>coordinatePagenum(pagenum); <🎜>showhiddenRecord(num); <🎜>}<BR>//--> <BR></script> <br> <br><br> </title> <br>; <br>共6 頁目前第<span id="number">1</span> 頁<br><span id="theFirstPage"><a href="javascript:firstPage()">第一頁</a> span> <br><span id="thePrePage"><a href="javascript:prePage()">上一頁</a></span> <br><span id="theNextPage"><a href="javascript:nextPage()">下一頁</a></span> <br><span id="theLastPage"><a href="javascript:lastPage()">最後一頁</a> </span> <br>轉到第<select onchange="gotoPage(this.value)" name="goto"> <br>1選項> <br>2選項> <br>3選項> <br>4選項> <br>5選項> <br>6選項> <br></select>頁<br> <br><br><table id="mytable" cellpadding="4" cellspacing="1" border="0" bgcolor="#999999" width="500align=center"> <br><tr bgcolor="#ffffff"><td>標題</td></tr> <br><tr bgcolor="#ffffff"> <td>1</td> <br> </tr> <tr bgcolor="#ffffff"><td>2</td></tr> <br><tr bgcolor="#ffffff"><td>3</td></tr> <br> <tr bgcolor="#ffffff"><td>4</td></tr> <br><tr bgcolor="#ffffff"><td>5</td></tr> <br><tr bgcolor="#ffffff"><td>6</td></tr> <br><tr bgcolor="#ffffff"><td>7</td></tr> <br><tr bgcolor="#ffffff"><td>8</td></tr> <br><tr bgcolor="#ffffff"><td>9</td></tr> <br><tr bgcolor="#ffffff"><td>10</td></tr> <br><tr bgcolor="#ffffff"><td>11</td></tr> <br><tr bgcolor="#ffffff"><td>12</td></tr> <br><tr bgcolor="#ffffff"><td>13</td></tr> <br><tr bgcolor="#ffffff"><td>14</td></tr> <br><tr bgcolor="#ffffff">15</tr> <br><tr bgcolor="#ffffff"><td>16</td></tr> <br><tr bgcolor="#ffffff"><td>17</td></tr> <br><tr bgcolor="#ffffff"><td>18</td></tr> <br><tr bgcolor="#ffffff"><td>19</td></tr> <br><tr bgcolor="#ffffff"><td>20</td></tr> <br><tr bgcolor="#ffffff"><td>21</td></tr> <br><tr bgcolor="#ffffff"><td>22</td></tr> <br><tr bgcolor="#ffffff"><td>23</td></tr> <br><tr bgcolor="#ffffff"><td> 24</td></tr> <br>表> <br>身體> <br> <br> </table></span> </div>