js实现ASP分页函数 HTML分页函数

所属分类: 网络编程 / JavaScript 阅读数: 2008
收藏 0 赞 0 分享
复制代码 代码如下:

<!--
//ASP分页函数
function ShowListPage(page,Pcount,TopicNum,maxperpage,strLink,ListName){
    var alertcolor = '#FF0000';
    maxperpage=Math.floor(maxperpage);
    TopicNum=Math.floor(TopicNum);
    page=Math.floor(page);
    var n,p;
    if ((page-1)%10==0) {
        p=(page-1) /10
    }else{
        p=(((page-1)-(page-1)%10)/10)
    }
    if(TopicNum%maxperpage==0) {
        n=TopicNum/maxperpage;
    }else{
        n=(TopicNum-TopicNum%maxperpage)/maxperpage+1;
    }
    document.write ('<table border="0" cellpadding="0" cellspacing="1" class="Tableborder5">');
    document.write ('<form method=post action="?pcount='+Pcount+strLink+'">');
    document.write ('<tr align="center">');
    document.write ('<td class="tabletitle1" title="'+ListName+'">&nbsp;'+ListName+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="总数">&nbsp;'+TopicNum+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="每页">&nbsp;'+maxperpage+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="页次">&nbsp;'+page+'/'+Pcount+'页&nbsp;</td>');
    if (page==1){
        document.write ('<td class="tablebody1">&nbsp;<font face=webdings>9</font>&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="?page=1'+strLink+'" title="首页"><font face=webdings>9</font></a>&nbsp;</td>');
    }
    if (p*10 > 0){
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+p*10+strLink+'" title="上十页"><font face=webdings>7</font></a>&nbsp;</td>');
    }
    if (page < 2){
        document.write ('<td class="tablebody1">&nbsp;首 页&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;上一页&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="?page=1'+strLink+'" title="首页">首 页</a>&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+(page-1)+strLink+'" title="上一页">上一页</a>&nbsp;</td>');
    }
    if (Pcount-page < 1){
        document.write ('<td class="tablebody1">&nbsp;下一页&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;尾 页&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+(page+1)+strLink+'" title="下一页">下一页</a>&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+Pcount+strLink+'" title="尾页">尾 页</a>&nbsp;</td>');
    }
    for (var i=p*10+1;i<p*10+11;i++){
        if (i==n) break;
    }
    if (i<n){
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+i+strLink+'" title="下十页"><font face=webdings>8</font></a>&nbsp;<td>');
    }
    if (page==n){
        document.write ('<td class="tablebody1">&nbsp;<Font face=webdings>:</font>&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="?page='+n+strLink+'" title="尾页"><font face=webdings>:</font></a>&nbsp;</td>');
    }
    document.write ('<td class="tablebody1"><input class="PageInput" type=text name="page" size=1 maxlength=10  value="'+page+'"></td>');
    document.write ('<td class="tablebody1"><input type=submit value=Go name=submit class="PageInput"></td>');
    document.write ('</tr>');
    document.write ('</form></table>');
}
//HTML分页函数
function ShowHtmlPage(page,Pcount,TopicNum,maxperpage,strLink,ExtName,ListName){
    var alertcolor = '#FF0000';
    maxperpage=Math.floor(maxperpage);
    TopicNum=Math.floor(TopicNum);
    page=Math.floor(page);
    var n,p;
    if ((page-1)%10==0) {
        p=(page-1) /10
    }else{
        p=(((page-1)-(page-1)%10)/10)
    }
    if(TopicNum%maxperpage==0) {
        n=TopicNum/maxperpage;
    }else{
        n=(TopicNum-TopicNum%maxperpage)/maxperpage+1;
    }
    document.write ('<table border="0" cellpadding="0" cellspacing="1" class="Tableborder5">');
    document.write ('<form method=post>');
    document.write ('<tr align="center">');
    document.write ('<td class="tabletitle1" title="'+ListName+'">&nbsp;'+ListName+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="总数">&nbsp;'+TopicNum+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="每页">&nbsp;'+maxperpage+'&nbsp;</td>');
    document.write ('<td class="tabletitle1" title="页次">&nbsp;'+page+'/'+Pcount+'页&nbsp;</td>');
    if (page==1){
        document.write ('<td class="tablebody1">&nbsp;<font face=webdings>9</font>&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="index'+ExtName+'" title="首页"><font face=webdings>9</font></a>&nbsp;</td>');
    }
    if (p*10 > 0){
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+(p*10)+ExtName+'" title="上十页"><font face=webdings>7</font></a>&nbsp;</td>');
    }
    if (page < 3){
        document.write ('<td class="tablebody1">&nbsp;首 页&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;<a href="index'+ExtName+'" title="上一页">上一页1</a>&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="index'+ExtName+'" title="首页">首 页1/a>&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+(page-1)+ExtName+'" title="上一页">上一页</a>&nbsp;</td>');
    }
    if (Pcount-page < 1){
        document.write ('<td class="tablebody1">&nbsp;下一页1&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;尾 页&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+(page+1)+ExtName+'" title="下一页">下一页</a>&nbsp;</td>');
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+Pcount+ExtName+'" title="尾页">尾 页</a>&nbsp;</td>');
    }
    for (var i=p*10+1;i<p*10+11;i++){
        if (i==n) break;
    }
    if (i<n){
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+i+ExtName+'" title="下十页"><font face=webdings>8</font></a>&nbsp;<td>');
    }
    if (page==n){
        document.write ('<td class="tablebody1">&nbsp;<Font face=webdings>:</font>&nbsp;</td>');
    }else{
        document.write ('<td class="tablebody1">&nbsp;<a href="'+strLink+n+ExtName+'" title="尾页"><font face=webdings>:</font></a>&nbsp;</td>');
    }
    //document.write ('<td class="tabletitle1" title="转到">&nbsp;GO&nbsp;</td>');
    document.write ('<td class="tablebody1"><select class="PageInput" name="page" size="1" onchange="javascript:window.location=this.options[this.selectedIndex].value;">');
    document.write ('<option value="index'+ExtName+'">第1页</option>');
    for (var i=2;i<TopicNum;i++){
        if (i==page){
            document.write ('<option value="'+strLink+i+ExtName+'" selected>第'+i+'页</option>');
        }else{
            if (i==1){
                document.write ('<option value="index'+ExtName+'">第1页</option>');
            }else{
                document.write ('<option value="'+strLink+i+ExtName+'">第'+i+'页</option>');
            }
        }
        if (i==n) break;
    }
    document.write ('</select></td>');
    document.write ('</tr>');
    document.write ('</form></table>');
}
//-->
更多精彩内容其他人还在看

Jquery-data的三种用法

本篇文章主要介绍了Jquery-data的三种用法。具有很好的参考价值。下面跟着小编一起来看下吧
收藏 0 赞 0 分享

微信小程序实战之自定义toast(6)

这篇文章主要为大家详细介绍了微信小程序实战之自定义toast的相关方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

微信小程序--onShareAppMessage分享参数用处(页面分享)

本篇文章主要介绍了微信小程序的页面分享onShareAppMessage分享参数用处的相关资料。具有很好的参考价值。下面跟着小编一起来看下吧
收藏 0 赞 0 分享

微信小程序实战之自定义抽屉菜单(7)

这篇文章主要为大家详细介绍了微信小程序实战之自定义抽屉菜单效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

微信小程序开发之从相册获取图片 使用相机拍照 本地图片上传

本篇文章主要介绍了微信小程序开发之从相册获取图片--使用相机拍照,本地图片上传的相关资料。具有很好的参考价值。下面跟着小编一起来看下吧
收藏 0 赞 0 分享

JavaScript错误处理和堆栈追踪详解

这篇文章主要为大家详细介绍了JavaScript错误处理和堆栈追踪的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

微信小程序开发之麦克风动画 帧动画 放大 淡出

本篇文章主要介绍了微信小程序开发之麦克风动画:帧动画、放大、淡出的相关资料。具有很好的参考价值。下面跟着小编一起来看下吧
收藏 0 赞 0 分享

微信小程序实战之自定义模态弹窗(8)

这篇文章主要为大家详细介绍了微信小程序实战之自定义模态弹窗,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

jQuery加密密码到cookie的实现代码

本文通过实例代码给大家分享了jquery 加密密码到cookie的实现方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧
收藏 0 赞 0 分享

javascript实现日期三级联动下拉框选择菜单

这篇文章主要介绍了javascript实现日期三级联动下拉框选择菜单,实现JS年月日三级联动下拉框选择功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享
查看更多