你的位置: Kiyo'Space首页 JavaScript/Jscript 阅读文章 欢迎留下您的足迹

日期控件

[ JavaScript/Jscript ] 分享

 

function rlCtrl()
   {
   // DateCtrl created by yyc  2000-6-18
   // Copyright (C) 2000.6 yyc, All Rights Reserved
   // this is a free class,but you must be reserve this comments
   // E-mail:yycmail@263.net
     var varMe,s,d,i;
     var len= rlCtrl.arguments.length;
     if (len>0)
     {
       varMe=rlCtrl.arguments[0];
       this.name=varMe;
       if (len>=4)
         {
           this.year=rlCtrl.arguments[1];
           this.month=rlCtrl.arguments[2];
           this.day=rlCtrl.arguments[3];
         }

       else
         {
          today=new Date();
          this.year=today.getYear();
          this.month=today.getMonth()+1;
          this.day=today.getDate();
         }

     this.getdate=getCurDate;
          
     document.writeln('<TABLE width=160px border=0 cellPadding=0 cellSpacing=0>');
     document.writeln('<TR><td>');
     d=new Date(this.year,this.month-1,this.day);
     i=d.getDay();
     s=getsweek(i);
     s=this.year+"年"+this.month+"月"+this.day+"日--"+s
     document.writeln('<INPUT  id=txt'+varMe+' name=txt'+varMe+'  ondblclick=\'opencls('+varMe+');\' style="FONT-SIZE: 9pt; FONT-STYLE: normal; HEIGHT: 20px; width:100%" value='+s+' readonly ></TD>');
     document.writeln('<TD width=15px>');
     document.writeln('<input type=button  onclick=\'opencls('+varMe+');\' style=" cursor:hand;FONT-SIZE: 8pt; FONT-STYLE: normal;" value="▼">');
      document.writeln('</TD></TR>');
     document.writeln("</table>");  
      
     document.writeln('<div id=div'+varMe+' name =div'+varMe+' style=" POSITION:absolute;display:none; WIDTH: 160px">');
     document.writeln('<TABLE id=tbl'+varMe+' name=tbl'+varMe+' WIDTH=100% BGCOLOR=#c0c0c0  onkeyup=\'doKey('+varMe+',window.event.keyCode) \' ALIGN=center style="COLOR: blue; FONT-SIZE: 9pt;" BORDER=1 CELLSPACING=1 CELLPADDING=1>');
     document.writeln("<TR><TD colspan=7>");
   document.writeln('<INPUT id=year'+varMe+' name=year'+varMe+' value='+this.year+' style="BACKGROUND-COLOR:transparent; BORDER-BOTTOM: green 0px solid;BORDER-LEFT: green 0px solid;BORDER-RIGHT: green 0px solid; BORDER-TOP: green 0px solid;COLOR: blue;CURSOR: hand; FONT-SIZE: 10pt; HEIGHT: 15px; MARGIN-TOP: 0pt; WIDTH: 35px" ');
   document.writeln('onmousemove   =\'javascript:if (this.readOnly)  {this.style.backgroundColor=0xffffff;  this.style.borderWidth=1;} \'');
   document.writeln('onmouseout =\'javascript: if (this.readOnly) { this.style.backgroundColor  ="transparent";this.style.borderWidth=0;} \' ');
   document.writeln('onclick=\'javascript: this.style.cursor="default"; this.readOnly=0; this.select(); this.focus(); \' ');
   document.writeln('onblur=\'javascript:this.style.backgroundColor="transparent"; this.style.borderWidth=0; this.style.cursor="hand"; this.readOnly=1; this.value='+varMe+'.year;dispDate('+varMe+'); \' '); //tbl'+varMe+'.focus();  
   document.writeln('onkeypress=\'javascript:if (window.event.keyCode==13||window.event.keyCode ==27){ if (window.event.keyCode==13) '+varMe+'.year=this.value;  this.blur();  }else if (window.event.keyCode<48||window.event.keyCode>57) window.event.keyCode =0;\'');
   document.writeln('readonly maxlength=4>');
    //=====================
     document.writeln('年<span style="cursor:hand" onclick=\''+varMe+'.year='+varMe+'.year+1;year'+varMe+'.innerText='+varMe+'.year;dispDate('+varMe+');\'>▲</span><span style="cursor:hand" onclick=\''+varMe+'.year='+varMe+'.year-1;year'+varMe+'.innerText='+varMe+'.year;dispDate('+varMe+');\'>▼</span>');
     document.writeln ('  ');
     document.writeln('<span id=month'+varMe+'>'+this.month+'</span>月<span style="cursor:hand" onclick=\''+varMe+'.month='+varMe+'.month+1;if('+varMe+'.month>12) '+varMe+'.month=1;month'+varMe+'.innerText='+varMe+'.month;dispDate('+varMe+');\'>▲</span><span style="cursor:hand" onclick=\''+varMe+'.month='+varMe+'.month-1;if('+varMe+'.month<1) '+varMe+'.month=12;month'+varMe+'.innerText='+varMe+'.month;dispDate('+varMe+');\'>▼</span>');
     document.writeln("</td></tr>");
      
     document.writeln('<TR style="COLOR: yellow; " bgcolor=DarkSlateBlue><TD>日</TD><TD>一</TD><TD>二</TD><TD>三</TD><TD>四</TD><TD>五</TD><TD>六</TD></TR>');

     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'0> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'1> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'2> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'3> </TD><TD  style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'4> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'5> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'6> </TD></TR>');
     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'7> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'8> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'9> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'10> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'11> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'12> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'13> </TD></TR>');
     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'14> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'15> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'16> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'17> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'18> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'19> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'20> </TD></TR>');
     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'21> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'22> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'23> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'24> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'25> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'26> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'27> </TD></TR>');
     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'28> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'29> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'30> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'31> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'32> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'33> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'34> </TD></TR>');
     document.writeln('<TR><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'35> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'36> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'37> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'38> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'39> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'40> </TD><TD style="cursor:hand" onclick=clkGrid(this,'+varMe+') id=td'+varMe+'41> </TD></TR>');
     document.writeln("</table></div>");    
       return this;
     }

     else
      {
        alert("初始化日历控件错误!!")
        return null;
      }

              
   }

欢迎在此留下您的脚步






评论内容 (*必填):
(Ctrl + Enter 快速提交)