zoukankan      html  css  js  c++  java
  • 梅花雨日历控件

    代码
    1 <HTML>
    2  <HEAD>
    3  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    4  <script>
    5
    6  */
    7 //==================================================== 参数设定部分 =======================================================
    8 var bMoveable=true; //设置日历是否可以拖动
    9 var _VersionInfo="Version:2.0 2.0作者:walkingpoison 1.0作者: F.R.Huang(meizz) MAIL: meizz@hzcnc.com" //版本信息
    10
    11 //==================================================== WEB 页面显示部分 =====================================================
    12 var strFrame; //存放日历层的HTML代码
    13 document.writeln('<iframe name=meizzDateLayer Author=wayx frameborder=0 style="position: absolute; 144; height: 211; z-index: 9998; visibility:hidden"></iframe>');
    14 strFrame='<style>';
    15 strFrame+='INPUT.button{BORDER-RIGHT:#86B9D2 1px solid;BORDER-TOP: #86B9D2 1px solid;BORDER-LEFT: #86B9D2 1px solid;';
    16 strFrame+='BORDER-BOTTOM: #86B9D2 1px solid;BACKGROUND-COLOR: #fff8ec;font-family:宋体;}';
    17 strFrame+='TD{FONT-SIZE: 9pt;font-family:宋体;}';
    18 strFrame+='A{text-decoration:none;font-weight:bold;color:black}';
    19 strFrame+='</style>';
    20 strFrame+='<scr' + 'ipt>';
    21 strFrame+='var datelayerx,datelayery; /*存放日历控件的鼠标位置*/';
    22 strFrame+='var bDrag; /*标记是否开始拖动*/';
    23 strFrame+='function document_onmousemove(e){/*在鼠标移动事件中,如果开始拖动日历,则移动日历*/';
    24 strFrame+='if(bDrag){';
    25 strFrame+=' var DateLayer=parent.document.getElementsByName("meizzDateLayer")[0].style;';
    26 strFrame+=' DateLayer.left = parseInt(DateLayer.left)+ e.clientX-datelayerx; /*由于每次移动以后鼠标位置都恢复为初始的位置,因此写法与div中不同*/';
    27 strFrame+='if(DateLayer.top=="")DateLayer.top=0;';
    28 strFrame+=' DateLayer.top = parseInt(DateLayer.top)+ e.clientY-datelayery;}}';
    29 strFrame+='function DragStart(e){ /*开始日历拖动*/';
    30 strFrame+="if ((document.all?e.button:e.which)!=1) return;\n";
    31 strFrame+='var DateLayer=parent.document.getElementsByName("meizzDateLayer")[0].style;';
    32 strFrame+=' datelayerx=e.clientX;';
    33 strFrame+=' datelayery=e.clientY;';
    34 strFrame+=' bDrag=true;}';
    35 strFrame+='function DragEnd(){ /*结束日历拖动*/';
    36 strFrame+=' bDrag=false;}';
    37 strFrame+='</scr' + 'ipt>';
    38 strFrame+='<body onmousemove="document_onmousemove(event)">';
    39 strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 19;visibility: hidden"></span>';
    40 strFrame+='<span id=tmpSelectMonthLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 78;visibility: hidden"></span>';
    41 strFrame+='<table border=1 cellspacing=0 cellpadding=0 width=142 height=160 bordercolor=#86B9D2 bgcolor=#86B9D2 Author="wayx">';
    42 strFrame+=' <tr Author="wayx"><td width=142 height=23 Author="wayx" bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 Author="wayx" height=23>';
    43 strFrame+=' <tr align=center Author="wayx"><td width=16 align=center bgcolor=#86B9D2';
    44 strFrame+=' onclick="parent.meizzPrevM()" title="向前翻 1 月" Author=meizz><a href="javascript:;" style="font-size:12px;color: #ffffff" Author=meizz><</a>';
    45 strFrame+=' </td><td width=60 align=center style="font-size:12px;cursor:default" Author=meizz ';
    46 strFrame+='onmouseover="style.backgroundColor=\'#FFD700\'" onmouseout="style.backgroundColor=\'white\'" ';
    47 strFrame+='onclick="parent.tmpSelectYearInnerHTML(innerHTML.match(/\\d{4}/).toString());" title="点击这里选择年份"><span Author=meizz id=meizzYearHead></span></td>';
    48 strFrame+='<td width=48 align=center style="font-size:12px;cursor:default" Author=meizz onmouseover="style.backgroundColor=\'#FFD700\'" ';
    49 strFrame+=' onmouseout="style.backgroundColor=\'white\'" onclick="parent.tmpSelectMonthInnerHTML(innerHTML.match(/\\d\\d?/).toString())"';
    50 strFrame+=' title="点击这里选择月份"><span id=meizzMonthHead Author=meizz></span></td>';
    51 strFrame+=' <td width=16 bgcolor=#86B9D2 align=center style="font-size:12px;cursor: hand;color: #ffffff" ';
    52 strFrame+=' onclick="parent.meizzNextM()" title="向后翻 1 月" Author=meizz><a href="javascript:;" style="font-size:12px;color: #ffffff;font:bold" Author=meizz>></a></td></tr>';
    53 strFrame+=' </table></td></tr>';
    54 strFrame+=' <tr Author="wayx"><td width=142 height=18 Author="wayx">';
    55 strFrame+='<table border=1 cellspacing=0 cellpadding=0 bgcolor=#86B9D2 ' + (bMoveable? 'onmousedown="DragStart(event)" onmouseup="DragEnd()"':'');
    56 strFrame+=' BORDERCOLORLIGHT=#86B9D2 BORDERCOLORDARK=#FFFFFF width=140 height=20 Author="wayx" style="cursor:' + (bMoveable ? 'move':'default') + '">';
    57 strFrame+='<tr Author="wayx" align=center valign=bottom><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>';
    58 strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>';
    59 strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>';
    60 strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>';
    61 strFrame+='</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: meizz@hzcnc.com 2002-10-8 -->';
    62 strFrame+=' <tr Author="wayx"><td width=142 height=120 Author="wayx">';
    63 strFrame+=' <table border=1 cellspacing=2 cellpadding=0 BORDERCOLORLIGHT=#FFFFFF BORDERCOLORDARK=#FFFFFF bgcolor=#86B9D2 width=140 height=120 Author="wayx">';
    64 var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center Author="wayx">'; for (i=0;i<7;i++){
    65 strFrame+='<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=parent.meizzDayClick(this.innerHTML.match(/\\d+/).toString(),0)></td>';n++;}
    66 strFrame+='</tr>';}
    67 strFrame+=' <tr align=center Author="wayx">';
    68 for (i=35;i<39;i++)strFrame+='<td width=20 height=20 id=meizzDay'+i+' style="font-size:12px" Author=wayx onclick="parent.meizzDayClick(this.innerHTML.match(/\\d+/).toString(),0)"></td>';
    69 strFrame+=' <td colspan=3 align=right Author=meizz><a href="javascript:;" onclick=parent.closeLayer() style="font-size:12px;text-decoration:underline;font-weight:300;"';
    70 strFrame+=' Author=meizz title="' + _VersionInfo + '">关闭</a> </td></tr>';
    71 strFrame+=' </table></td></tr><tr Author="wayx"><td Author="wayx">';
    72 strFrame+=' <table border=0 cellspacing=1 cellpadding=0 width=100% Author="wayx" bgcolor=#FFFFFF>';
    73 strFrame+=' <tr Author="wayx"><td Author=meizz align=left><input Author=meizz type=button class=button value="<<" title="向前翻 1 年" onclick="parent.meizzPrevY()" ';
    74 strFrame+=' onfocus="this.blur()" style="font-size: 12px; height: 20px"><input Author=meizz class=button title="向前翻 1 月" type=button ';
    75 strFrame+=' value="< " onclick="parent.meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td><td ';
    76 strFrame+=' Author=meizz align=center><input Author=meizz type=button class=button value=Today onclick="parent.meizzToday()" ';
    77 strFrame+=' onfocus="this.blur()" title="当前日期" style="font-size: 12px; height: 20px; cursor:hand"></td><td ';
    78 strFrame+=' Author=meizz align=right><input Author=meizz type=button class=button value=" >" onclick="parent.meizzNextM()" ';
    79 strFrame+=' onfocus="this.blur()" title="向后翻 1 月" class=button style="font-size: 12px; height: 20px"><input ';
    80 strFrame+=' Author=meizz type=button class=button value=">>" title="向后翻 1 年" onclick="parent.meizzNextY()"';
    81 strFrame+=' onfocus="this.blur()" style="font-size: 12px; height: 20px"></td>';
    82 strFrame+='</tr></table></td></tr></table></div></body>';
    83 var odatelayer;
    84 var outObject;
    85 var outButton; //点击的按钮
    86 var outDate=""; //存放对象的日期
    87 function init(){
    88 window.frames.meizzDateLayer.document.writeln(strFrame);
    89 window.frames.meizzDateLayer.document.close(); //解决ie进度条不结束的问题
    90 odatelayer=window.frames.meizzDateLayer.document; //存放日历对象
    91 }
    92 //==================================================== WEB 页面显示部分 ======================================================
    93
    94 function setday(tt,obj) //主调函数
    95 {
    96 if (arguments.length > 2){alert("对不起!传入本控件的参数太多!");return;}
    97 if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
    98 var dads = document.getElementsByName("meizzDateLayer")[0].style;
    99 var th = tt;
    100 var ttop = tt.offsetTop; //TT控件的定位点高
    101 var thei = tt.offsetHeight; //TT控件本身的高
    102 var tleft = tt.offsetLeft; //TT控件的定位点宽
    103 var ttyp = tt.type; //TT控件的类型
    104 while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
    105 dads.top = ttop+thei ;
    106 dads.left = tleft;
    107 outObject = (arguments.length == 1) ? th : obj;
    108 outButton = (arguments.length == 1) ? null : th; //设定外部点击的按钮
    109 //根据当前输入框的日期显示日历的年月
    110 var reg = /^(\d+)-(\d{1,2})-(\d{1,2})$/;
    111 var r = outObject.value.match(reg);
    112 if(r!=null){
    113 r[2]=r[2]-1;
    114 var d= new Date(r[1], r[2],r[3]);
    115 if(d.getFullYear()==r[1] && d.getMonth()==r[2] && d.getDate()==r[3]){
    116 outDate=d; //保存外部传入的日期
    117 }
    118 else outDate="";
    119 meizzSetDay(r[1],r[2]+1);
    120 }
    121 else{
    122 outDate="";
    123 meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1);
    124 }
    125 dads.visibility="visible";
    126 document.getElementsByName("meizzDateLayer")[0].focus();
    127 event.returnValue=false;
    128 }
    129
    130 var MonHead = new Array(12); //定义阳历中每个月的最大天数
    131 MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
    132 MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;
    133
    134 var meizzTheYear=new Date().getFullYear(); //定义年的变量的初始值
    135 var meizzTheMonth=new Date().getMonth()+1; //定义月的变量的初始值
    136 var meizzWDay=new Array(39); //定义写日期的数组
    137
    138 function document_onclick(e) //任意点击时关闭该控件 //ie6的情况可以由下面的切换焦点处理代替
    139 {
    140 var elm = (document.all)?(e.srcElement):(e.target);
    141 if ((elm.getAttribute("Author")==null || elm.getAttribute("Author")=="") && elm != outObject && elm != outButton)
    142 closeLayer();
    143 }
    144
    145 function document_onkeyup(e) //按Esc键关闭,切换焦点关闭
    146 {
    147 if (window.event.keyCode==27){
    148 if(outObject)outObject.blur();
    149 closeLayer();
    150 }
    151 else if(document.activeElement)
    152 if(document.activeElement.getAttribute("Author")==null && document.activeElement != outObject && document.activeElement != outButton)
    153 {
    154 closeLayer();
    155 }
    156 }
    157
    158 function meizzWriteHead(yy,mm) //往 head 中写入当前的年与月
    159 {
    160 odatelayer.getElementById("meizzYearHead").innerHTML = yy + "";
    161 odatelayer.getElementById("meizzMonthHead").innerHTML = mm + "";
    162 }
    163
    164 function tmpSelectYearInnerHTML(strYear) //年份的下拉框
    165 {
    166 if (strYear.match(/\D/)!=null){alert("年份输入参数不是数字!");return;}
    167 var m = (strYear) ? strYear : new Date().getFullYear();
    168 if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
    169 var n = m - 10;
    170 if (n < 1000) n = 1000;
    171 if (n + 26 > 9999) n = 9974;
    172 var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
    173 s += "onblur='document.getElementById(\"tmpSelectYearLayer\").style.visibility=\"hidden\"' "
    174 s += "onchange='blur();"
    175 s += "parent.meizzTheYear = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n";
    176 var selectInnerHTML = s;
    177 for (var i = n; i < n + 26; i++)
    178 {
    179 if (i == m)
    180 {selectInnerHTML += "<option Author=wayx value='" + i + "' selected>" + i + "" + "</option>\r\n";}
    181 else {selectInnerHTML += "<option Author=wayx value='" + i + "'>" + i + "" + "</option>\r\n";}
    182 }
    183 selectInnerHTML += "</select>";
    184 odatelayer.getElementById("tmpSelectYearLayer").innerHTML = selectInnerHTML;
    185 odatelayer.getElementById("tmpSelectYearLayer").style.visibility="visible";
    186 odatelayer.getElementsByName("tmpSelectYear")[0].focus();
    187
    188 }
    189
    190 function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
    191 {
    192 if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
    193 var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
    194 var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
    195 s += "onblur='document.getElementById(\"tmpSelectMonthLayer\").style.visibility=\"hidden\"' "
    196 s += "onchange='blur();"
    197 s += "parent.meizzTheMonth = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n";
    198 var selectInnerHTML = s;
    199 for (var i = 1; i < 13; i++)
    200 {
    201 if (i == m)
    202 {selectInnerHTML += "<option Author=wayx value='"+i+"' selected>"+i+""+"</option>\r\n";}
    203 else {selectInnerHTML += "<option Author=wayx value='"+i+"'>"+i+""+"</option>\r\n";}
    204 }
    205 selectInnerHTML += "</select>";
    206 odatelayer.getElementById("tmpSelectMonthLayer").style.visibility="visible";
    207 odatelayer.getElementById("tmpSelectMonthLayer").innerHTML = selectInnerHTML;
    208 odatelayer.getElementsByName("tmpSelectMonth")[0].focus();
    209 }
    210
    211 function closeLayer() //这个层的关闭
    212 {
    213 document.getElementsByName("meizzDateLayer")[0].style.visibility="hidden";
    214 }
    215
    216 function IsPinYear(year) //判断是否闰平年
    217 {
    218 if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
    219 }
    220
    221 function GetMonthCount(year,month) //闰年二月为29天
    222 {
    223 var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
    224 }
    225 function GetDOW(day,month,year) //求某天的星期几
    226 {
    227 var dt=new Date(year,month-1,day).getDay()/7; return dt;
    228 }
    229
    230 function meizzPrevY() //往前翻 Year
    231 {
    232 if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
    233 else{alert("年份超出范围(1000-9999)!");}
    234 meizzSetDay(meizzTheYear,meizzTheMonth);
    235 }
    236 function meizzNextY() //往后翻 Year
    237 {
    238 if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
    239 else{alert("年份超出范围(1000-9999)!");}
    240 meizzSetDay(meizzTheYear,meizzTheMonth);
    241 }
    242 function meizzToday() //Today Button
    243 {
    244 var today;
    245 meizzTheYear = new Date().getFullYear();
    246 meizzTheMonth = new Date().getMonth()+1;
    247 today=new Date().getDate();
    248 //meizzSetDay(meizzTheYear,meizzTheMonth);
    249 if(outObject){
    250 outObject.value=meizzTheYear + "-" + meizzTheMonth + "-" + today;
    251 }
    252 closeLayer();
    253 }
    254 function meizzPrevM() //往前翻月份
    255 {
    256 if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
    257 meizzSetDay(meizzTheYear,meizzTheMonth);
    258 }
    259 function meizzNextM() //往后翻月份
    260 {
    261 if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
    262 meizzSetDay(meizzTheYear,meizzTheMonth);
    263 }
    264
    265 function meizzSetDay(yy,mm) //主要的写程序**********
    266 {
    267 meizzWriteHead(yy,mm);
    268 //设置当前年月的公共变量为传入值
    269 meizzTheYear=yy;
    270 meizzTheMonth=mm;
    271 for (var i = 0; i < 39; i++){meizzWDay[i]=""}; //将显示框的内容全部清空
    272 var day1 = 1,day2=1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期几
    273 for (i=0;i<firstday;i++)meizzWDay[i]=GetMonthCount(mm==1?yy-1:yy,mm==1?12:mm-1)-firstday+i+1 //上个月的最后几天
    274 for (i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
    275 for (i=firstday+GetMonthCount(yy,mm);i<39;i++){meizzWDay[i]=day2;day2++}
    276 for (i = 0; i < 39; i++)
    277 { var da = odatelayer.getElementById("meizzDay"+i); //书写新的一个月的日期星期排列
    278 if (meizzWDay[i]!="")
    279 {
    280 //初始化边框
    281 da.style.borderWidth="1px";
    282 da.style.borderStyle="solid";
    283 da.style.borderTopColor="#FFFFFF";
    284 da.style.borderRightColor="#FFFFFF";
    285 da.style.borderBottomColor="#FFFFFF";
    286 da.style.borderLeftColor="#FFFFFF";
    287 if(i<firstday) //上个月的部分
    288 {
    289 da.innerHTML="<a href='javascript:;'><font color=gray>" + meizzWDay[i] + "</font></a>";
    290 da.title=(mm==1?12:mm-1) +"" + meizzWDay[i] + "";
    291 da.onclick=Function("meizzDayClick(this.innerHTML.match(/\\d+/).toString(),-1)");
    292 if(!outDate)
    293 da.style.backgroundColor = ((mm==1?yy-1:yy) == new Date().getFullYear() &&
    294 (mm==1?12:mm-1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ?
    295 "#FFFFFF":"#e0e0e0";
    296 else
    297 {
    298 da.style.backgroundColor =((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 &&
    299 meizzWDay[i]==outDate.getDate())? "#86B9D2" :
    300 (((mm==1?yy-1:yy) == new Date().getFullYear() && (mm==1?12:mm-1) == new Date().getMonth()+1 &&
    301 meizzWDay[i] == new Date().getDate()) ? "#FFFFFF":"#e0e0e0");
    302 //将选中的日期显示为凹下去
    303 if((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 &&
    304 meizzWDay[i]==outDate.getDate())
    305 {
    306 da.style.borderTopColor="#FFFFFF";
    307 da.style.borderRightColor="#FFFFFF";
    308 da.style.borderBottomColor="#FFFFFF";
    309 da.style.borderLeftColor="#FFFFFF";
    310 }
    311 }
    312 }
    313 else if (i>=firstday+GetMonthCount(yy,mm)) //下个月的部分
    314 {
    315 da.innerHTML="<a href='javascript:;'><font color=gray>" + meizzWDay[i] + "</font></a>";
    316 da.title=(mm%12+1) +"" + meizzWDay[i] + "";
    317 da.onclick=Function("meizzDayClick(this.innerHTML.match(/\\d+/).toString(),1)");
    318 if(!outDate)
    319 da.style.backgroundColor = ((mm==12?yy+1:yy) == new Date().getFullYear() &&
    320 (mm==12?1:mm+1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ?
    321 "#FFFFFF":"#e0e0e0";
    322 else
    323 {
    324 da.style.backgroundColor =((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 &&
    325 meizzWDay[i]==outDate.getDate())? "#86B9D2" :
    326 (((mm==12?yy+1:yy) == new Date().getFullYear() && (mm==12?1:mm+1) == new Date().getMonth()+1 &&
    327 meizzWDay[i] == new Date().getDate()) ? "#FFFFFF":"#e0e0e0");
    328 //将选中的日期显示为凹下去
    329 if((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 &&
    330 meizzWDay[i]==outDate.getDate())
    331 {
    332 da.style.borderTopColor="#FFFFFF";
    333 da.style.borderRightColor="#FFFFFF";
    334 da.style.borderBottomColor="#FFFFFF";
    335 da.style.borderLeftColor="#FFFFFF";
    336 }
    337 }
    338 }
    339 else //本月的部分
    340 {
    341 da.innerHTML="<a href='javascript:;'>" + meizzWDay[i] + "</a>";
    342 da.title=mm +"" + meizzWDay[i] + "";
    343 da.onclick=Function("meizzDayClick(this.innerHTML.match(/\\d+/).toString(),0)"); //给td赋予onclick事件的处理
    344 //如果是当前选择的日期,则显示亮蓝色的背景;如果是当前日期,则显示暗黄色背景
    345 if(!outDate)
    346 da.style.backgroundColor = (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate())?
    347 "#FFFFFF":"#e0e0e0";
    348 else
    349 {
    350 da.style.backgroundColor =(yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())?
    351 "#86B9D2":((yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate())?
    352 "#FFFFFF":"#e0e0e0");
    353 //将选中的日期显示为凹下去
    354 if(yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())
    355 {
    356 da.style.borderTopColor="#FFFFFF";
    357 da.style.borderRightColor="#FFFFFF";
    358 da.style.borderBottomColor="#FFFFFF";
    359 da.style.borderLeftColor="#FFFFFF";
    360 }
    361 }
    362 }
    363 da.style.cursor="hand"
    364 }
    365 else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
    366 }
    367 }
    368
    369 function meizzDayClick(n,ex) //点击显示框选取日期,主输入函数*************
    370 {
    371 var yy=meizzTheYear;
    372 var mm = parseInt(meizzTheMonth)+ex; //ex表示偏移量,用于选择上个月份和下个月份的日期
    373 //判断月份,并进行对应的处理
    374 if(mm<1){
    375 yy--;
    376 mm=12+mm;
    377 }
    378 else if(mm>12){
    379 yy++;
    380 mm=mm-12;
    381 }
    382
    383 if (mm < 10){mm = "0" + mm;}
    384 if (outObject)
    385 {
    386 if (!n) {//outObject.value="";
    387 return;}
    388 if ( n < 10){n = "0" + n;}
    389 outObject.value= yy + "-" + mm + "-" + n ; //注:在这里你可以输出改成你想要的格式
    390 closeLayer();
    391 }
    392 else {closeLayer(); alert("您所要输出的控件对象并不存在!");}
    393 }
    394
    395 // -->
    396 </script>
    397 </HEAD>
    398
    399 <BODY onclick="document_onclick(event)" onkeyup="document_onkeyup(event)" onload="init()">
    400 <input name=txt onfocus="setday(this)"><img src="date.gif" onclick="setday(this,document.getElementsByName('txt')[0])"> <br>
    401
    402 </BODY>
    403 </HTML>
    404
    405
  • 相关阅读:
    python 进程、线程、协程感悟
    elk部署心得
    虚拟安装centos后无法上网、DNS无法解析问题解决
    mysql测试题
    爬取lol皮肤
    ping使用
    第一篇技术博客
    PADS layout修改字符时发生严重错误退出问题
    PADS 快捷键
    电容知识整理
  • 原文地址:https://www.cnblogs.com/pfs1314/p/1681943.html
Copyright © 2011-2022 走看看