• 日期选择原始版


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

    找日历的东东,不咋好用,索性自己弄个。这是最初原版,当个备份。
  • 相关阅读:
    oracle mybatis 模糊查询
    IntelliJ IDEA各种引入jar包的方式及其关系
    eclipse中新建Java工程的三个JRE选项区别
    @Autowired注解和@resource注解的区别
    结合测试,黑盒测试
    Oracle左连接、右连接、全外连接以及(+)号用法
    samePropertyValuesAs()
    Collection.sort 的用法
    junit withcapture
    单元测试
  • 原文地址:https://www.cnblogs.com/jiang_zheng/p/1575675.html
Copyright © 2020-2023  润新知