zoukankan      html  css  js  c++  java
  • 日期选择原始版

    <style type="text/css">        
            .CDclear {float:none;clear:both;height:0px;line-height:0px;overflow:hidden;font-size:1px;}
            .CDblank, .CDtdw, a.CDtda, a.CDtdas {display:block;20px;height:20px; line-height:20px; float:left; overflow:hidden; text-align:center; cursor:default;}
            .CDblank { overflow:hidden;font-size:1px;}
            .CDtdw   { }
            a.CDtda   { text-decoration:none; color:#444444;}        
            a.CDtdas  {text-decoration:none; color:#444444; background-color:#EFEFEF;}
            a.CDtda:hover ,a.CDtdas:hover { background-color:#FF9900;}
        </style>
        
        <script language="javascript" type="text/javascript">              
            //构造日历显示
            function GoQian(thisYear, thisMonth, thisDay) {
            
                var DaysCount = new Date(thisYear, thisMonth, 0).getDate(); //月的总天数

                var startDays = new Date(thisYear + '/' + thisMonth + '/1').getDay(); //月开始的天数是周几

                var goYearl = thisMonth == 1 ? thisYear - 1 : thisYear; //前翻的年
                var goYearr = thisMonth == 12 ? thisYear + 1 : thisYear; //后翻到年
                var goMonthl = thisMonth == 1 ? 12 : thisMonth - 1; //前翻的月
                var goMonthr = thisMonth == 12 ? 1 : thisMonth + 1; //后翻到月

                var weekDays = new Array('日', '一', '二', '三', '四', '五', '六');
                
                var br = '<br class="CDclear" />'; // 清除浮动

                var s = [];
                
                s.push('<table style="140px;" cellspacing="0" cellpadding="0">');            
                s.push('<tr>');
                s.push('<td style="20px;text-align:center;"><a href="javascript:GoQian(' + goYearl + ',' + goMonthl + ',' + thisDay + ');">&lt;</a></td>'); //上一月
                s.push('<td style="100px;text-align:center;">' + thisYear + '/' + thisMonth + '</td>');
                s.push('<td style="20px;text-align:center;"><a href="javascript:GoQian(' + goYearr + ',' + goMonthr + ',' + thisDay + ');">&gt;</a></td>'); //下一月
                s.push('</tr>');
                s.push('</table>');
                

                s.push('<div style="140px;">');
                //显示周数
                for (var j = 0; j < weekDays.length; j++) {
                    s.push('<a class="CDtdw">' + weekDays[j] + '</a>');
                }
                s.push(br + '</div>');

                
                s.push('<div style="140px;">');
                //开始的空格构造
                for (var x = 0; x < startDays; x++) {
                    s.push('<a class="CDblank"></a>');
                }
                
                //实际显示
                for (var y = startDays, ds = 1; ds <= DaysCount; y++) {
                    s.push('<a class="' + (ds == thisDay ? 'CDtdas' : 'CDtda') + '" href="javascript:;" onclick="javascript:SetDateToControl(\'' + thisYear + '-' + thisMonth + '-' + ds + '\');">' + ds + '</a>');
                    ds++;
                }
                s.push(br + '</div>');

                document.getElementById('Calendar1').innerHTML = s.join('');
                s.length = 0;
            }
            
            function SetDateToControl(arg){alert(arg)}

            var CurDate = new Date();
            var tDay = CurDate.getDate();
            var tMonth = CurDate.getMonth() + 1;  //0-11 实际月份要加一
            var tYear = CurDate.getFullYear();

            GoQian(tYear, tMonth, tDay);
            </script>

    找日历的东东,不咋好用,索性自己弄个。这是最初原版,当个备份。
  • 相关阅读:
    sql server 2005的分页函数ROW_NUMBER
    Silverlight 皮肤(主题)动态切换
    Silverlight 地图导航
    WPF模板概述(数据模板)
    Silverlight MVVM Prism WCF RIA项目框架
    多线程通中的AutoResetEvent与ManualResetEvent
    Silverlight 图形报表 线形图 柱形图 饼图
    WPF 重要新概念读书笔记(转)
    Net基本概念和原理
    数据库辅助工具SqlDbx
  • 原文地址:https://www.cnblogs.com/jiang_zheng/p/1575675.html
Copyright © 2011-2022 走看看