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>
  • 相关阅读:
    UVa 1595
    求树直径及所有直径顶点

    python-sort()/sorted()比较
    MNIST数据集分类简单版本
    Tensorlflow-解决非线性回归问题
    Tensorlflow-神经网络解决非线性回归问题
    tensorflow基础-placeholder
    Tensorflow基础-mnist数据集
    Week 3: Structured Types 5. Tuples and Lists Exercise: odd tuples
  • 原文地址:https://www.cnblogs.com/shapaozi/p/7058909.html
Copyright © 2011-2022 走看看