JS+Ajax+Jquery实现页面无刷新分页以及分组 超强的实现第1/2页

 更新时间:2009年08月26日 01:26:46   作者:   我要评论
JS+Ajax+Jquery实现页面无刷新分页以及分组 超强的实现 加上你的CSS完全可以与EXT媲美哦
复制代码 代码如下:

<%@ Page language="c#" Codebehind="GroupText.aspx.cs" AutoEventWireup="false" Inherits="test1.GroupText" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>GroupText</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
        <LINK href="css/wmh.css" href="css/wmh.css" type="text/css" rel="stylesheet">
        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="js/Common.js" type="text/javascript"></script>
        <script src="js/getCommonTable.js" type="text/javascript"></script>
        <script src="js/GroupText.js" type="text/javascript"></script>
        <script language="javascript"><!--
        var ecid = '100001';
        var jpstr = "";
        var pageSize = 8;

        
// --></script>

    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <div class="listDiv" style="height:100%; PADDING-TOP: 2px">
                <table cellSpacing="0" cellPadding="0" width="100%" border="0">
                    <tr class="dg_header">
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center" >活动名称</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">发送方</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">接收方</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 12%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">发送时间</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 38%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">发送内容</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">积分</td>
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">状态</td>
                    </tr>
                    <tr>
                        <td class="dg_line" style="BORDER-BOTTOM: 0px solid" style="BORDER-BOTTOM: 0px solid" vAlign="top" width="100%" colSpan="7"
                            height="100%">
                            <div id="divcontent" style="WIDTH: 100%; HEIGHT: 100%" align="left"></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="dg_line" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid"
                            width="100%" colSpan="10">
                            <table width="100%">
                                <tr>
                                    <td class="pgtext">共<span id="recordcount" style="COLOR: red" style="COLOR: red">0</span>条记录   
                                        目前第<span id="curpageindex" style="COLOR: red" style="COLOR: red">0</span> <font color="red">/</font><span id="pgcount" style="COLOR: red" style="COLOR: red">0</span>页   
                                        <input class="pageText" id="gototxt" type="text" maxLength="10" name="gototxt" runat="server">
                                        <input id="gotopg" type="button" class="goBtn"></td>
                                    <td align="right"><IMG id="btnfirst" style="CURSOR: hand" style="CURSOR: hand" alt="首页" src="Images/first.gif">
                                        <IMG id="btnpre" style="CURSOR: hand" style="CURSOR: hand" alt="上一页" src="Images/btn_pre.gif" > <IMG id="btnnext" style="CURSOR: hand" style="CURSOR: hand" alt="下一页" src="Images/btn_next.gif" >
                                        <IMG id="btnlast" style="CURSOR: hand" style="CURSOR: hand" alt="尾页" src="Images/btn_last.gif" >
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </body>
</HTML>

Common.js
复制代码 代码如下:

Common.js:
//时间格式化

function getDateByFormat(oldDate){
                var Dy = oldDate.getFullYear();
                var Dm = oldDate.getMonth()+1;
                var Dd = oldDate.getDate();
                if(Dm<10){
                    Dm = "0" + Dm;
                }
                if(Dd<10){
                    Dd = "0" + Dd;
                }
                var newDate = Dy+'-'+Dm+'-'+Dd;

                    return newDate;
                }
//日期-时间格式化
function getDateTimeByFormat(oldDate){
                var Dy = oldDate.getFullYear();
                var Dm = oldDate.getMonth()+1;
                var Dd = oldDate.getDate();
                var Dh = oldDate.getHours();
                var Dmi = oldDate.getMinutes();  
                var Ds    = oldDate.getSeconds();   
                if(Dm<10)
                    Dm = "0" + Dm;
                if(Dd<10)
                    Dd = "0" + Dd;

                if(Dh<10)
                 Dh = "0" + Dh;
                if(Dmi<10)
                    Dmi = "0" + Dmi;
                if(Ds<10)
                    Ds = "0" + Ds;

                var newDate = Dy+'-'+Dm+'-'+Dd+' '+Dh+':'+Dmi+':'+Ds;
                    return newDate;
                }

//只能输入数字
function txtnumber()
            {
                if ((event.keyCode >57) || (event.keyCode <48))
                    return false;else return true;
            }

        //只能输入数字和字母

    function txtnumchar()
            { //65- 90 97-122
                var kcode = event.keyCode;
                if (kcode >= 48 && kcode <= 57)
                    return true;
                else if(kcode >= 65 && kcode <= 90)
                    return true;
                else if (kcode >= 97 && kcode <= 122)
                    return true;
                else
                    return false;
            }

getCommonTable.js
复制代码 代码如下:

getCommonTable.js
//获取table头
         function getTableHeadByWidth(widthSize,ids){
         var Tableone = "<table id='tab"+ids+"' border='0' cellspacing='0' cellpadding='0' ";
         var Tabletwo = ">";
         if (widthSize == "")
         return Tableone + Tabletwo;
         else
         return Tableone+"width="+widthSize+Tabletwo;

        }

        
//获取第一个tr td 传一个宽度值
        function getTrAndTdFirstByCWidth(classname,widthSize){
         var tdone = " <tr ";
         var tdtwo = "><td style="BORDER-BOTTOM: 1px solid;" style="BORDER-BOTTOM: 1px solid;" align='center' ";
         var tdthr = " > ";
         if (classname =="")
         tdone += tdtwo;
         else
         tdone+=" class ='"+classname+"' "+tdtwo;

         if (widthSize == "")
         tdone += tdthr;
         else
         tdone += " width="+widthSize+tdthr;

         return tdone;
        }

        //获取下一个TD,传一个宽度值
        function getTdNextByWidth(widthSize){
         var tdone = " </td><td style=" BORDER-BOTTOM: 1px solid" style=" BORDER-BOTTOM: 1px solid" align='center' ";
         var tdtwo =">";
         if (widthSize =="")
         return tdone+tdtwo;
         else
         return tdone+"width="+widthSize+tdtwo;
        }

        //获取最后一个td
        function getTdLastByWidth(widthSize){
         var tdone = " </td><td style=" BORDER-BOTTOM: 1px solid" style=" BORDER-BOTTOM: 1px solid" align='center' ";
         var tdtwo =">";
         if (widthSize =="")
         return tdone+tdtwo;
         else
         return tdone+"width="+widthSize+tdtwo;
        }
        //获取最后一个tr/td
        function getTrAndTdLast(){
         return " </td></tr>";
        }

        
        //获取table尾
        function getTableLast(){
         return "</table>";
        }

        //获取img
        function getImgByParams(imgUrl,altstr,eventName,eventParams,imgid){
         var one = "<img border='0' style="CURSOR: hand" style="CURSOR: hand"";
         if (imgUrl != "")
         one += "src='"+imgUrl+"'";
         if (altstr != "")
         one += "alt='"+altstr+"'";
         if(imgid != "")
         one += "id='"+imgid+"'";

         one += "onclick='"+eventName+"("+eventParams+");'> ";

         return one
        }

//--------排序---------------------------
            //通过字段的内容排序
        SortByBtnidAndCellName=function(btnId,cellName,celltype){
            var way =    getOpType(btnId);//0为正。1为倒
            var ds = userdata.value;
            var sortarr= new Array();
            if ((ds!= null) && (typeof(ds) == "object")){
             var len = ds.Rows.length;
             if(celltype=='S' || celltype=='N'){
                        for(var j=0;j<len;j++){
                            sortarr[j] = ds.Rows[j][cellName];//.substr(0,1);//通过字符
                            }
                    }else if(celltype=='D'){
                        for(var i=0;i<len;i++){
                                    sortarr[i] = getDateByFormat(ds.Rows[i][cellName]);//通过日期
                            }
                    }
                if(sortarr!=''){
                    var indexarr = new Array();
                    indexarr = getSortArray(sortarr,celltype);//得到新的排序规则
                    if(indexarr != ''){
                        setSortAginbyWay(indexarr,way);
                    }
                }
            }
        }

        //获得排序
        getOpType=function(btnid){//返回0正序,1为倒序
            var imgName= $("#"+btnid).attr("src");
            var wz = imgName.indexOf('.gif');
            var oldImg =imgName.substr(wz-9,9);
            if(oldImg=='sort_desc'){//当前是倒序或未排序,需要正序sort_ascc
                $("#"+btnid).attr("src","../Images/sort_ascc.gif");
                return 0;
            }else{
                $("#"+btnid).attr("src","../Images/sort_desc.gif");
                return 1;
            }

        }
        //按JS Sort排序 获得新的排序规则
        getSortArray=function (sortdatearr,celltype){// 参数为array
                var sortstr = '';
                for(var k=0;k<sortdatearr.length;k++){
                if(sortstr=='')
                        sortstr=sortdatearr[k];
                    else
                        sortstr+='^%^'+sortdatearr[k];
                }
                var newsortdate =sortdatearr;
                var len = sortdatearr.length;

                    if(celltype =='S' || celltype =='D')
                        newsortdate.sort();//字符排序
                    else{ //数字排序
                        for(var i=0;i<len;i++){
                            var tmp =0;
                            for(var j=i+1;j<len;j++){
                                if(newsortdate[i]>newsortdate[j]){
                                    tmp = newsortdate[i];
                                    newsortdate[i] = newsortdate[j];
                                    newsortdate[j] =tmp;
                                }
                            }
                        }
                    }

             var tmpsortdate =sortstr.split('^%^')

             var resultarr = new Array();
             for(var i = 0;i<len;i++){
                    for(var j = 0;j<len;j++){
                     if(newsortdate[i]==tmpsortdate[j]){
                            resultarr[i] = j;
                            tmpsortdate[j] ='||||||||';
                            break;
                     }
                    }
             }

             return resultarr;
        };

//--------------------end-------------------------------
//删除重复的手机号码
SplitRepeatMobile=function(mobile){
    var mob=mobile;
    for(var i=0;i<mob.length;i++){
        for(var j=i+1;j<mob.length;j++){
            if(mob[i]==mob[j]){
                mob.splice(j,1);
            }
        }
    }
    return mob;
}

相关文章

  • 屏蔽网页右键复制和ctrl+c复制的js代码

    屏蔽网页右键复制和ctrl+c复制的js代码

    解决的方法就是直接把网页保存下来然后删掉下面这段js代码,然后就可以正常用右键菜单,也可以通过设置浏览器的安全级别到最高级别来解决问题
    2013-01-01
  • JS实现的简单鼠标跟随DiV层效果完整实例

    JS实现的简单鼠标跟随DiV层效果完整实例

    这篇文章主要介绍了JS实现的简单鼠标跟随DiV层效果,涉及JavaScript基于时间函数动态操作页面元素属性的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-10-10
  • Javascript 关于基本类型和引用类型的个人理解

    Javascript 关于基本类型和引用类型的个人理解

    这篇文章主要介绍了Javascript 关于基本类型和引用类型的个人理解,需要的朋友可以参考下
    2019-11-11
  • 5个最佳的Javascript日期处理类库分享

    5个最佳的Javascript日期处理类库分享

    在大家日常网站开发和web应用开发中,我们往往需要有效的调用Javascript处理日期和时间格式相关的函数,在Javascript中已经包含了部分最基本的内建处理方法
    2012-04-04
  • 跟我学习javascript的函数调用和构造函数调用

    跟我学习javascript的函数调用和构造函数调用

    跟我学习javascript的函数和构造函数调用,主要包括三方面内容函数调用、方法调用以及构造函数调用,想要了解这些内容的朋友千万不要错过下面的内容。
    2015-11-11
  • JS实现屏蔽网页右键复制及ctrl+c复制的方法【2种方法】

    JS实现屏蔽网页右键复制及ctrl+c复制的方法【2种方法】

    这篇文章主要介绍了JS实现屏蔽网页右键复制及ctrl+c复制的方法,结合实例形式分析了2种比较常用的屏蔽复制功能的技巧,需要的朋友可以参考下
    2016-09-09
  • js仿百度音乐全选操作

    js仿百度音乐全选操作

    这篇文章主要为大家详细介绍了js仿百度音乐全选操作,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-01-01
  • 微信小程序websocket聊天室的实现示例代码

    微信小程序websocket聊天室的实现示例代码

    这篇文章主要介绍了微信小程序websocket聊天室的实现示例代码,小程序本身对http、websocket等连接均有诸多限制,所以这次项目选择了node.js自带的ws模块。感兴趣的可以参考一下
    2019-02-02
  • 用函数式编程技术编写优美的 JavaScript_ibm

    用函数式编程技术编写优美的 JavaScript_ibm

    函数式编程语言在学术领域已经存在相当长一段时间了,但是从历史上看,它们没有丰富的工具和库可供使用。随着 .NET 平台上的 Haskell 的出现,函数式编程变得更加流行。一些传统的编程语言,例如 C++ 和 JavaScript,引入了由函数式编程提供的一些构造和特性。在许多情况下,JavaScript 的重复代码导致了一些拙劣的编码。如果使用函数式编程,就可以避免这些问题。此外,可以利用函数式编程风格编写更加优美的回调。
    2008-05-05
  • 为什么JS中eval处理JSON数据要加括号

    为什么JS中eval处理JSON数据要加括号

    这篇文章主要介绍了为什么JS中eval处理JSON数据要加括号的相关资料,需要的朋友可以参考下
    2015-04-04

最新评论