zoukankan      html  css  js  c++  java
  • javascript分页显示

     //根据条件查找数据
    list = Stdqj.FindAll(where, "ID desc", "", (pageindex - 1) * 15, 15);
    // 根据list查找的条件,查找list的总数(count)           
        ViewBag.total = Stdqj.FindCount(where);
    //在传递参数中传递pageindex
    //获取当前pageindex的值
                    ViewBag.pageindex = pageindex;
                }
                return View(list);
     <div id="pager">
                    <a href="javascript:;" onclick="goPage(1)">首页</a>
    //pageindex如果大于1:pageindex=3(当前页=3)则存在第1页第2页,允许点击上一页
                    @if (ViewBag.pageindex > 1)
                    {
                        <a href="javascript:;" onclick="goPage(@(ViewBag.pageindex - 1))">上一页</a>
                    }
                    else
                    {
                        <a href="javascript:;" class="noContent">上一页</a>
                    }
    //如果数量大于当前页pageindex*15则允许点击下一页/末页
                    @if (ViewBag.total > ViewBag.pageindex * 15)
                    {
                        <a href="javascript:;" onclick="goPage(@(ViewBag.pageindex + 1))" class="noContent">下一页</a>
    //向上取整
                        <a href="javascript:;" onclick="goPage(@(Math.Ceiling(Convert.ToDouble(ViewBag.total)/15)))" class="noContent">末页</a>
                    }
                    else {
                        <a href="javascript:;" class="noContent">下一页</a>
                        <a href="javascript:;" class="noContent">末页</a>
                    }
                </div>
                <script type="text/javascript">
        goPage = (function (page) {
            var s = window.location.href;
            if (/pageindex=/.test(s))
                s = s.replace(/pageindex=[0-9]*/, "pageindex=" + page);
            else
                s = s + "&pageindex=" + page;
            if (!/?/.test(s))
                s = s.replace("&", "?");
            window.location.href = s;
        });
                </script>
  • 相关阅读:
    Spring AOP切点表达式用法总结
    各种文档地址记录
    回顾乐信集团工作经历
    Redux的简单使用
    简单介绍软件测试(一)
    jupyter notebook 安装代码提示功能
    解决matplotlib不显示中文的问题
    前端生成二维码并下载(PC端)
    XSS绕过常见方式
    JWT的安全问题
  • 原文地址:https://www.cnblogs.com/shapaozi/p/7058909.html
Copyright © 2011-2022 走看看