源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

js下通过getList函数实现分页效果的代码

  • 时间:2020-11-17 09:20 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:js下通过getList函数实现分页效果的代码
用js实现页面的分页:
[url=javascript:void(0)]<a href="javascript:void(0)" onclick="getPage(1)" style="visibility :visible " id="next">下一页</a> <a href="javascript:void(0)" onclick="getPage(0)" style="visibility :visible ">首页</a> <a href="javascript:void(0)" onclick="getPage(11)">尾 页</a> <form name="form1" id="form2"> <select name='PageCtl1_select' id="select" onchange='SD_Web_PageCtlGoOtherPage(this.value);' style="width: 30px"></select> //按下拉显示页数 </form> </td> </tr> </table>
getPage()为js函数,如下:
//参数说明:lblPostsCount:总共记录条数,由getActivityCount获得;iPageIndex:全局变量,当前页数 function getPage(page) { if(page==0)//回到首页 { iPageIndex=1; document.form1.PageCtl1_select.options[iPageIndex-1].selected="true"; //下拉框显示第几页,数组从0开始 getActivityList(1); } else if(page==11)//回到尾页 { iPageIndex=Math.round (lblPostsCount/6); document.form1.PageCtl1_select.options[iPageIndex-1].selected="true"; getActivityList(iPageIndex); } else //上一页,下一页 { iPageIndex=iPageIndex+page; if(iPageIndex<=0) //如果是第一页还点上一页,还是保持在第一页 iPageIndex=1; else if(iPageIndex>Math.round (lblPostsCount/6))//如果是最后一页还点下一页,保持在最后一页 iPageIndex=Math.round (lblPostsCount/6); else { document.form1.PageCtl1_select.options[iPageIndex-1].selected="true"; getActivityList(iPageIndex);//调用List清单 } } } function getActivityCount() //获取记录条数 { 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; //记录总数   document.form1.PageCtl1_select.length=0; //初始下拉框,把页数付给下拉框的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); } }
按下拉框显示第几页函数:
[u]复制代码[/u] 代码如下:
function SD_Web_PageCtlGoOtherPage(pageNo) { getActivityList(pageNo); }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部