日期:2014-05-17 浏览次数:20677 次
<script> var theTable = document.getElementById("tablelsw"); var totalPage = document.getElementById("spanTotalPage"); var pageNum = document.getElementById("spanPageNum"); var spanPre = document.getElementById("spanPre"); var spanNext = document.getElementById("spanNext"); var spanFirst = document.getElementById("spanFirst"); var spanLast = document.getElementById("spanLast"); var totalPaget = document.getElementById("spanTotalPaget"); var pageNumt = document.getElementById("spanPageNumt"); var spanPret = document.getElementById("spanPret"); var spanNextt = document.getElementById("spanNextt"); var spanFirstt = document.getElementById("spanFirstt"); var spanLastt = document.getElementById("spanLastt"); var numberRowsInTable = theTable.rows.length; var pageSize = 5; var page = 1; //下一页 function next() { hideTable(); currentRow = pageSize * page; maxRow = currentRow + pageSize; if ( maxRow > numberRowsInTable ) maxRow = numberRowsInTable; for ( var i = currentRow; i<maxRow; i++ ){ theTable.rows[i].style.display = ''; } page++; if ( maxRow == numberRowsInTable ) { nextText(); lastText(); } else{ nextLink(); } preLink(); firstLink(); } //上一页 function pre() { hideTable(); page--; currentRow = pageSize * page; maxRow = currentRow - pageSize; if ( currentRow > numberRowsInTable ) currentRow = numberRowsInTable; for ( var i = maxRow; i<currentRow; i++ ) { theTable.rows[i].style.display = ''; } if ( maxRow == 0 ) { preText(); firstText(); } preLink(); nextLink(); lastLink(); } //第一页 function first(){ hideTable(); page = 1; for ( var i = 0; i<pageSize; i++ ){ theTable.rows[i].style.display = ''; } showPage(); preText(); nextLink(); lastLink(); } //最后一页 function last() { hideTable(); page = pageCount(); currentRow = pageSize * (page - 1); for ( var i = currentRow; i<numberRowsInTable; i++ ) { theTable.rows[i].style.display = ''; } showPage(); preLink(); nextText(); firstLink(); } function hideTable() { for ( var i = 0; i<numberRowsInTable; i++ ) { theTable.rows[i].style.display = 'none'; } } function showPage() { pagepageNum.innerHTML = page; pagepageNumt.innerHTML = page; } //总共页数 function pageCount() { var count = 0; if ( numberRowsInTable%pageSize != 0 ) count = 1; return parseInt(numberRowsInTable/pageSize) + count; } function pageNow() { var nowpage = 0; if ( numberRowsInTable%pageSize != 0 ) count = 1; return parseInt(