最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Javascript實(shí)現(xiàn)的分頁(yè)函數(shù)

 更新時(shí)間:2007年02月07日 00:00:00   作者:  

/**
 * 分頁(yè)類構(gòu)造
 * 參數(shù) nTotalList: 總條數(shù)
 * 參數(shù) nPageSize: 每頁(yè)顯示條數(shù)
 * 參數(shù) nPageNum: 當(dāng)前頁(yè)碼
 * 參數(shù) sPageUrl: 分頁(yè)鏈接的URL,頁(yè)碼以[pn]代替,輸出時(shí)將被替換為實(shí)際頁(yè)碼
 * 參數(shù) nPageListSize: 頁(yè)碼列表(下拉框)中顯示的最多頁(yè)碼條數(shù)。該參數(shù)可省略,默認(rèn)100
 */
function Pagination(nTotalList, nPageSize, nPageNum, sPageUrl, nPageListSize) {
  this.totalList = nTotalList;
  this.pageSize = nPageSize;
  this.pageNum = nPageNum;
  if (nTotalList == 0)
    this.totalPages = 1;
  else
    this.totalPages = Math.floor((this.totalList-1)/this.pageSize + 1);
  this.pageUrl = sPageUrl;
  if (arguments[4])
    this.pageListSize = nPageListSize;
  else
    this.pageListSize = 100;
}

/**
 * 生成分頁(yè),將HTML直接輸出
 * 無(wú)參數(shù)
 * 無(wú)返回值
 */
Pagination.prototype.generate = function() {
  var output = "";
  output += "<table width=\"98%\" cellspacing=\"1\" cellpadding=\"3\" align=\"center\"><tr><td align=\"right\">";
  output += "共 " + this.totalList + " 條 每頁(yè) " + this.pageSize + " 條 當(dāng)前第 ";
  output += "<select onchange=\"if(this.value)location.href='" + this.pageUrl + "'.replace(/\\[pn\\]/,";
  output += "this.value);\" align=\"absMiddle\" style=\"font:normal 9px Verdana,Arial,宋體;\">";
  var firstPage = this.pageNum - Math.floor(this.pageListSize/2);
  if (firstPage < 1)
    firstPage = 1;
  var lastPage = firstPage + this.pageListSize - 1;
  if (lastPage > this.totalPages) {
    lastPage = this.totalPages;
    firstPage = lastPage - this.pageListSize + 1;
    if (firstPage < 1)
      firstPage = 1;
  }
  if (firstPage > 1) {
    output += "<option value=\"1\">1</option>";
    if (firstPage > 2)
      output += "<option value=\"\">…</option>";
  }
  for (var p = firstPage; p <= lastPage; p++) {
    output += "<option value=\"" + p + "\"";
    if (p == this.pageNum)
      output += " selected=\"yes\"";
    output += ">" + p + "</option>";
  }
  if (lastPage < this.totalPages) {
    if (lastPage < this.totalPages - 1)
      output += "<option value=\"\">…</option>";
    output += "<option value=\"" + this.totalPages + "\">" + this.totalPages + "</option>";
  }
  if (this.pageNum > this.totalPages)
    output += "<option value=\"\" selected=\"yes\">頁(yè)碼超出范圍</option>";
  output += "</select>";
  output += "/" + this.totalPages + " 頁(yè) ";
  if (this.pageNum == 1) {
    output += "[首頁(yè)] ";
    output += "[上頁(yè)] ";
  }
  else {
    output += "<a href=\"" + this.pageUrl.replace(/\[pn\]/, "1") + "\">[首頁(yè)]</a> ";
    output += "<a href=\"" + this.pageUrl.replace(/\[pn\]/, this.pageNum-1) + "\">[上頁(yè)]</a> ";
  }
  if (this.pageNum == this.totalPages) {
    output += "[下頁(yè)] ";
    output += "[尾頁(yè)]";
  }
  else {
    output += "<a href=\"" + this.pageUrl.replace(/\[pn\]/, this.pageNum+1) + "\">[下頁(yè)]</a> ";
    output += "<a href=\"" + this.pageUrl.replace(/\[pn\]/, this.totalPages) + "\">[尾頁(yè)]</a> ";
  }
  output += "</td></tr></table>";
  document.writeln(output);
}

相關(guān)文章

  • 一個(gè)友好的.改善的 Object.prototype.toString的實(shí)現(xiàn)

    一個(gè)友好的.改善的 Object.prototype.toString的實(shí)現(xiàn)

    一個(gè)友好的.改善的 Object.prototype.toString的實(shí)現(xiàn)...
    2007-04-04
  • js計(jì)算德州撲克牌面值的方法

    js計(jì)算德州撲克牌面值的方法

    這篇文章主要介紹了js計(jì)算德州撲克牌面值的方法,實(shí)例分析了javascript計(jì)算撲克面值的算法技巧,需要的朋友可以參考下
    2015-03-03
  • Bootstrap Chart組件使用教程

    Bootstrap Chart組件使用教程

    圖表組件Chart.js是Bootstrap比較好用的組件之一,與一款收費(fèi)的組件highchart類似,效果上來(lái)看免費(fèi)與收費(fèi)的產(chǎn)品相差還是有一點(diǎn)點(diǎn)的,不過(guò)功能上差不多能滿足我們項(xiàng)目的需要,本文給大家介紹Bootstrap Chart組件使用,需要的朋友參考下吧
    2016-04-04
  • 實(shí)例講解javascript注冊(cè)事件處理函數(shù)

    實(shí)例講解javascript注冊(cè)事件處理函數(shù)

    這篇文章主要以實(shí)例的方式向大家介紹了javascript注冊(cè)事件處理函數(shù),內(nèi)容很全面,感興趣的朋友可以參考一下
    2016-01-01
  • JavaScript內(nèi)置日期、時(shí)間格式化時(shí)間實(shí)例代碼

    JavaScript內(nèi)置日期、時(shí)間格式化時(shí)間實(shí)例代碼

    JS中的 Date 對(duì)象用于處理日期和時(shí)間,Date對(duì)象和Math對(duì)象不一樣,Date是一個(gè)構(gòu)造函數(shù),需要實(shí)例化后才能使用對(duì)象中具體的方法和屬性。這篇文章主要給大家介紹了關(guān)于JavaScript內(nèi)置日期、時(shí)間格式化時(shí)間的相關(guān)資料,需要的朋友可以參考下
    2021-05-05
  • JS獲取隨機(jī)數(shù)和時(shí)間轉(zhuǎn)換的簡(jiǎn)單實(shí)例

    JS獲取隨機(jī)數(shù)和時(shí)間轉(zhuǎn)換的簡(jiǎn)單實(shí)例

    下面小編就為大家?guī)?lái)一篇JS獲取隨機(jī)數(shù)和時(shí)間轉(zhuǎn)換的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-07-07
  • JavaScript實(shí)現(xiàn)九宮格移動(dòng)拼圖游戲

    JavaScript實(shí)現(xiàn)九宮格移動(dòng)拼圖游戲

    這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)九宮格移動(dòng)拼圖游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • layui點(diǎn)擊左側(cè)導(dǎo)航欄,實(shí)現(xiàn)不刷新整個(gè)頁(yè)面,只刷新局部的方法

    layui點(diǎn)擊左側(cè)導(dǎo)航欄,實(shí)現(xiàn)不刷新整個(gè)頁(yè)面,只刷新局部的方法

    今天小編就為大家分享一篇layui點(diǎn)擊左側(cè)導(dǎo)航欄,實(shí)現(xiàn)不刷新整個(gè)頁(yè)面,只刷新局部的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-09-09
  • JS字典Dictionary類定義與用法示例

    JS字典Dictionary類定義與用法示例

    這篇文章主要介紹了JS字典Dictionary類定義與用法,結(jié)合實(shí)例形式分析了javascript字典Dictionary的定義、添加、移除、統(tǒng)計(jì)等相關(guān)操作技巧,需要的朋友可以參考下
    2019-02-02
  • uni-file-picker文件選擇上傳功能實(shí)現(xiàn)代碼

    uni-file-picker文件選擇上傳功能實(shí)現(xiàn)代碼

    本文介紹了uni-file-picker的基礎(chǔ)使用方法,包括選擇圖片的九宮格樣式、限制選擇的圖片數(shù)量、指定圖片類型及后綴,以及如何自定義上傳時(shí)機(jī),詳細(xì)說(shuō)明了如何通過(guò)設(shè)置不同的屬性來(lái)實(shí)現(xiàn)圖片的選擇和上傳,適用于需要在應(yīng)用中上傳圖片的開(kāi)發(fā)者
    2024-09-09

最新評(píng)論

道真| 共和县| 海兴县| 九龙城区| 自贡市| 汤原县| 南涧| 大余县| 陆川县| 紫阳县| 吕梁市| 涟水县| 山东省| 贵州省| 扎赉特旗| 东明县| 新丰县| 双牌县| 惠来县| 南溪县| 汉源县| 桃江县| 曲阜市| 南昌县| 四子王旗| 鞍山市| 银川市| 明星| 昌都县| 遂溪县| 乐清市| 乌兰察布市| 南川市| 烟台市| 邯郸县| 铜梁县| 五台县| 自治县| 莱州市| 玛纳斯县| 象州县|