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>

    找日历的东东,不咋好用,索性自己弄个。这是最初原版,当个备份。
  • 相关阅读:
    DEV GridView显示行号
    winfrom Log4Net 代码(二) 记录格式log_info.txt和log_error.txt,只产生两个文本,里面分别记录提示信息和报错信息
    VB.NET使用Log4Net
    Log4Net使用中loginfo.IsInfoEnabled=false问题解决方法
    VB.NET 根据当前日期获取星期几
    VB.NET 发送outLook邮件body基于Html样式
    VB.NET NPOI快速导入导出Excel
    python使用cx_oracle连接oracle数据库
    物理STANDBY库创建还原点(打开为READ WRITE后再变回STANDBY库)
    oracle RAC和RACOneNode之间的转换
  • 原文地址:https://www.cnblogs.com/jiang_zheng/p/1575675.html
Copyright © 2011-2022 走看看