• 日期选择原始版


    <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>

    找日历的东东,不咋好用,索性自己弄个。这是最初原版,当个备份。
  • 相关阅读:
    Xhprof分析php性能
    Xhprof graphviz Warning: proc_open() [function.proc-open]: CreateProcess failed, error code 解决方法
    使用xhprof会在nginx下报502 Bad Gateway错误
    springbooot2 thymeleaf 配置以及加载资源文件。Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
    springboot用户登陆密码两次md5加密
    SpringBoot2.0 redis生成组建和读写配置文件
    spring2.0:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either th
    SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe
    秋季学期总结
    寒假作业3:抓老鼠啊~亏了还是赚了?
  • 原文地址:https://www.cnblogs.com/jiang_zheng/p/1575675.html
Copyright © 2020-2023  润新知