国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

js下通過(guò)getList函數(shù)實(shí)現(xiàn)分頁(yè)效果的代碼

2019-11-21 00:14:20
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
用js實(shí)現(xiàn)頁(yè)面的分頁(yè):

復(fù)制代碼 代碼如下:

<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#D2EBF3;" height="32">
<tr><td align="right" bgColor="#f7f7f7" height="36">
<a href="javascript:void(0)" onclick="getPage(-1)" style="visibility :visible " id="up">上一頁(yè)</a>
<a href="javascript:void(0)" onclick="getPage(1)" style="visibility :visible " id="next">下一頁(yè)</a>
<a href="javascript:void(0)" onclick="getPage(0)" style="visibility :visible ">首頁(yè)</a>
<a href="javascript:void(0)" onclick="getPage(11)">尾 頁(yè)</a>
<form name="form1" id="form2">
<select name='PageCtl1_select' id="select" onchange='SD_Web_PageCtlGoOtherPage(this.value);' style="width: 30px"></select> //按下拉顯示頁(yè)數(shù)
</form>
</td> </tr>
</table>

getPage()為js函數(shù),如下:

復(fù)制代碼 代碼如下:

//參數(shù)說(shuō)明:lblPostsCount:總共記錄條數(shù),由getActivityCount獲得;iPageIndex:全局變量,當(dāng)前頁(yè)數(shù)
function getPage(page)
{
if(page==0)//回到首頁(yè)
{
iPageIndex=1;
document.form1.PageCtl1_select.options[iPageIndex-1].selected="true"; //下拉框顯示第幾頁(yè),數(shù)組從0開(kāi)始
getActivityList(1);
}
else if(page==11)//回到尾頁(yè)
{

iPageIndex=Math.round (lblPostsCount/6);
document.form1.PageCtl1_select.options[iPageIndex-1].selected="true";
getActivityList(iPageIndex);
}
else //上一頁(yè),下一頁(yè)
{
iPageIndex=iPageIndex+page;
if(iPageIndex<=0) //如果是第一頁(yè)還點(diǎn)上一頁(yè),還是保持在第一頁(yè)
iPageIndex=1;
else if(iPageIndex>Math.round (lblPostsCount/6))//如果是最后一頁(yè)還點(diǎn)下一頁(yè),保持在最后一頁(yè)
iPageIndex=Math.round (lblPostsCount/6);
else
{
document.form1.PageCtl1_select.options[iPageIndex-1].selected="true";
getActivityList(iPageIndex);//調(diào)用List清單
}
}
}

function getActivityCount() //獲取記錄條數(shù)
{
var variable=['strWhere'];
var value=new Array(1);
value[0]="iStatus=2 and iPublic=5";
newRequest("getActivityCount",variable,value,getAllActivityCountShow);
beginRequest();
}
function getAllActivityCountShow()
{
var xmlhttp=xmlHttpRequest;
  var str=xmlhttp.responseText;
   var value=GetValue(str,"getActivityCountResult");
   lblPostsCount=value; //記錄總數(shù)
  document.form1.PageCtl1_select.length=0; //初始下拉框,把頁(yè)數(shù)付給下拉框的value值和text顯示;
for(i=1;i<=Math.round (lblPostsCount/6);i++)
{
var option=document.createElement("option");
option.value=i;
option.text=i;
document.form1.PageCtl1_select.options.add(option);
}
}


按下拉框顯示第幾頁(yè)函數(shù):

復(fù)制代碼 代碼如下:

function SD_Web_PageCtlGoOtherPage(pageNo)
{
getActivityList(pageNo);
}
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 综艺| 宁乡县| 林口县| 阿拉善右旗| 马山县| 阿合奇县| 柯坪县| 东至县| 连州市| 舞阳县| 大洼县| 乌兰浩特市| 晋城| 岳西县| 富顺县| 新建县| 留坝县| 青海省| 延吉市| 蒙自县| 沙坪坝区| 米脂县| 锦屏县| 定日县| 青海省| 江源县| 尚志市| 武宁县| 庆云县| 陇川县| 全南县| 仙桃市| 柳河县| 洮南市| 泰和县| 尉氏县| 安远县| 西充县| 奉化市| 晋州市| 彭山县|