<script type="text/javascript">
function GetWeekday()
{
var weekday = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
var arrInput = document.getElementById("t1").value.split("-");
if (arrInput.length < 3)
alert ("error input");
else
{
var d = new Date(arrInput[0], arrInput[1] - 1, arrInput[2]);
document.getElementById("t2").value = weekday[d.getDay()];
}
}
</script>
<input type="text" id="t1">
<input type="button" value="go" onclick="javascript:GetWeekday();">
<input type="text" id="t2">

解决方案 »

  1.   

    验证格式的函数没写
    <script type="text/javascript">
    function GetWeekday()
    {
    var arrInput = document.getElementById("t1").value.split("-");
    var d = new Date(arrInput[0], arrInput[1] - 1, arrInput[2]);
    document.getElementById("t2").value = "星期"+"日一二三四五六".charAt(d.getDay());
    }
    </script>
    <input type="text" id="t1">
    <input type="button" value="go" onclick="javascript:GetWeekday();">
    <input type="text" id="t2">
      

  2.   

    <body>格式为:2007/04/16
    <input id="txt" type="text" onblur="a()"></br>
    <input id="txt1" type="text" value="" >
    <script language="javascript">
    function a(){
    var wek=new Array(7);
    wek[0]="星期日";
    wek[1]="星期一";
    wek[2]="星期二";
    wek[3]="星期三";
    wek[4]="星期四";
    wek[5]="星期五";
    wek[6]="星期六";var txt=document.getElementById("txt");
    var txt1=document.getElementById("txt1");
    var txt_value=txt.value;
    alert(txt_value);
    ind=(new Date(txt_value)).getDay();
    txt1.value=wek[ind];
    }</script>
    </body>
      

  3.   

    偶是LZ謝謝chuckcoin() ,hbhbhbhbhb1021(天外水火(我要多努力)) ,melodywithme() 我需要的是在文本框中选中日期(格式:2007-04-16,用日历)!不需要用botton,另一文本框中直接显示星期!结帖时,我会多加点分,你们三位肯定会给!!用日历!!!用日历!!!用日历!!!
      

  4.   

    去找个js的calendar控件,onchange事件触发就行
      

  5.   

    <script language="javascript">
    Date.prototype.format="yyyy-MM-dd hh:mm:ss";
    Date.prototype.Regex={
    "regex1" : /([\$\(\)\*\+\.\[\]\?\\\^\{\}\|])/g ,
    "regex2" : /(y+|M+|d+|m+|h+|s+)/g ,
    "year1" : /^y{1,2}$/ ,
    "year2" : /^y{4}$/ ,
    "month" : /^M{1,2}$/ ,
    "day" : /^d{1,2}$/ ,
    "hour" : /^h{1,2}$/i ,
    "minute" : /^m{1,2}$/ ,
    "second" : /^s{1,2}$/
    }
    Date.prototype.setFormatDate = function() //author : gzdiablo
    {
    var A = arguments;
    var inputStr = "";
    var sformat = this.format;
    if(A.length==0 && A.length>2){return this;}
    if(A.length==1){inputStr = A[0];}
    if(A.length==2){inputStr = A[0];sformat = A[1];}
    if(sformat == null && inputStr == null)return this;
    var tempint = Date.parse(inputStr);
    if(!isNaN(tempint))this.setTime(tempint);
    var tempregex = new RegExp(sformat.replace(this.Regex["regex1"],"\\$1").replace(this.Regex["regex2"],"(\\d+)"));
    var temparr = sformat.match(this.Regex["regex2"]);
    var temparr2 = inputStr.match(tempregex);
    if(temparr2!=null && temparr!=null)
    {
    if(temparr2.length>1)temparr2.shift();
    for(var i=0;i<temparr.length && temparr2[i]!=null;i++)
    {
    switch(true)
    {
    case this.Regex["year1"].test(temparr[i]):this.setFullYear(temparr2[i]*1 + 2000);break;
    case this.Regex["year2"].test(temparr[i]):this.setFullYear(temparr2[i]*1);break;
    case this.Regex["month"].test(temparr[i]):this.setMonth(temparr2[i]*1-1);break;
    case this.Regex["day"].test(temparr[i]):this.setDate(temparr2[i]*1);break;
    case this.Regex["hour"].test(temparr[i]):this.setHours(temparr2[i]*1);break;
    case this.Regex["minute"].test(temparr[i]):this.setMinutes(temparr2[i]*1);break;
    case this.Regex["second"].test(temparr[i]):this.setSeconds(temparr2[i]*1);break;
    }
    }
    }
    return this;
    }
    //以上是日期类扩展var aa = new Date();
    aa.format = "yyyy-MM-dd";//你需要的日期格式
    aa.setFormatDate(document.getElementById("text1").value);
    document.getElementById("text1").value = "星期"+"日一二三四五六".charAt(aa.getDay());
    </script>假设 文本框1内容为 "公元2007年4月17日"
    那么你就根据内容设定Date.format为 "公元yyyy年MM月dd日"
    然后用Date.setFormatDate("文本框1的内容"); 就可以得到这个日期了
      

  6.   

    偶是LZ
    <script type="text/javascript">
    function GetWeekday()
    {
    var arrInput = document.getElementById("t1").value.split("-");
    var d = new Date(arrInput[0], arrInput[1] - 1, arrInput[2]);
    document.getElementById("t2").value = "星期"+"日一二三四五六".charAt(d.getDay());
    }
    </script>
    输入日期﹕<input type="text" id="t1" name="t1" onblur="GetWeekday(this.value)">
    得到星期﹕<input type="text" id="t2" name="t2">
    像这种方法,但是输入日期直接点日历就行(速度!!!!)解决后,马上给分!!用日历!!!用日历!!!用日历!!!
      

  7.   

    <html>
    <head><title></title>
    <script>
    function getWeek(v)
    {
    var dar=v.split("-");
    var week=new  Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
    var date=new Date(eval(dar[0]),eval(dar[1])-1,eval(dar[2]));
    document.all.t2.value=week[date.getDay()];
    }
    </script>
    </head>
    <body>
    <input id="t1" type="text" onpropertychange="getWeek(this.value)" value="2007-04-16" /><br>
    <input id="t2" type="text"/>
    </body></html>
      

  8.   

    <script   language=javascript>   
      function   getDay(mydate)   
      {   
            var   date1   =   mydate;   
            var   year1,month1,day1;   
            var   newDate,newDay;   
            re   =   /^(\d{2,4})-(\d{1,2})-(\d{1,2})$/g;   
            if((date1!="")&&(re.test(mydate)))   
            {   
                    year1   =   date1.replace(re,"$1");   
                    month1=   date1.replace(re,"$2");   
                    day1=   date1.replace(re,"$3");   
                    newDate   =   new   Date(year1,month1,day1);   
                    newDay   =   newDate.getDay();   
                    SetTxtValue(newDay,document.all.dayTxt.value)   
            }   
      }   
        
      function   SetTxtValue(newDay)   
      {   
              if(newDay==0)   document.all.dayTxt.value=   "星期五";   
              if(newDay==1)   document.all.dayTxt.value=   "星期六";   
              if(newDay==2)   document.all.dayTxt.value=   "星期日";   
              if(newDay==3)   document.all.dayTxt.value=   "星期一";   
              if(newDay==4)   document.all.dayTxt.value=   "星期二";   
              if(newDay==5)   document.all.dayTxt.value=   "星期三";   
              if(newDay==6)   document.all.dayTxt.value=   "星期四";       
      }   
        
      </script>   
      输入日期:<input   type="text"     name="dateTxt"     id="dateTxt"     onblur="getDay(this.value)"><br>   
      得到星期:<input   type="text"     name="dayTxt"     id="dayTxt">  
    可惜用的不是日历!!共同进步!!楼下的回答!!
      

  9.   

    <body>
    <input id="date" type="text" onkeyup="dateToweek()" maxlength="10"></br>
    <input id="week" type="text" value="" >
    <script language="javascript">
    function dateToweek(){
    var wek=new Array(7);
    wek[0]="星期日";
    wek[1]="星期一";
    wek[2]="星期二";
    wek[3]="星期三";
    wek[4]="星期四";
    wek[5]="星期五";
    wek[6]="星期六";var date=document.getElementById("date");
    var week=document.getElementById("week");
    var datevalue=date.value;
    if(datevalue.length == 4){date.value += '/';}
    if(datevalue.length == 7){date.value += '/';}
    if(datevalue.length >=8)
    {
    ind=(new Date(datevalue)).getDay();
    if(isNumber(ind) && ind >= 0){
    week.value=wek[ind];
    }
    }
    else if(datevalue.length < 8)
    {
    week.value = "";
    }
    }
    function isNumber(obj){ 
       return (typeof obj=='number')&&obj.constructor==Number; 
    }
    </script>
    </body>
      

  10.   

    http://www.blogjava.net/mxx/archive/2006/09/27/72159.html
    常用公历日期处理程序 "星期" + "日一二三四五六".charAt(date.getDay());
      

  11.   

    日历控件一大堆
    有空就自己写,不想的话就google一个就好
      

  12.   

    在CSDN搜日期控件,多得是结果
    自己选择一个用吧.
      

  13.   

    偶是LZ﹗誰知道怎么做﹗﹗﹗
    請發到[email protected]!!!
    謝謝﹗﹗
      

  14.   

    zhaoxiaoyang(梅雪香@深圳) ( ) 信誉:100    Blog   加为好友 
    老大不是偶懒!!偶在网上找了些日期控件!没解决问题,才在这里求助!!
      

  15.   

    <script language=javascript>
    <!--
    document.writeln('<div id=meizzDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
    document.writeln('<span id=tmpSelectYearLayer  style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
    document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
    document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#808080 onselectstart="return false">');
    document.writeln('  <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
    document.writeln('      <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
    document.writeln('        onclick="meizzPrevM()" title="向前翻 月" Author=meizz><b Author=meizz>&lt;&lt;</b>');
    document.writeln('        </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
    document.writeln('        <span Author=meizz id=meizzYearHead onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
    document.writeln('         id=meizzMonthHead Author=meizz onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
    document.writeln('        <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
    document.writeln('         onclick="meizzNextM()" title="往后翻 月" Author=meizz><b Author=meizz>&gt;&gt;</b></td></tr>');
    document.writeln('    </table></td></tr>');
    document.writeln('  <tr><td width=142 height=18 bgcolor=#808080>');
    document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
    document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>');
    document.writeln('</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: [email protected] 2002-10-8 -->');
    document.writeln('  <tr><td width=142 height=120>');
    document.writeln('    <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF>');
    var n=0; for (j=0;j<5;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
    document.writeln('<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=meizzDayClick(this.innerText)></td>');n++;}
    document.writeln('</tr>');}
    document.writeln('      <tr align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
    document.writeln('         onclick=meizzDayClick(this.innerText)></td>');
    document.writeln('        <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz onclick=meizzDayClick(this.innerText)></td></tr>');
    document.writeln('    </table></td></tr><tr><td>');
    document.writeln('        <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
    document.writeln('          <tr><td Author=meizz align=left><input Author=meizz type=button value="<<" title="向前翻 年" onclick="meizzPrevY()" ');
    document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"><input Author=meizz title="向前翻 月" type=button ');
    document.writeln('             value="<" onclick="meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td><td ');
    document.writeln('             Author=meizz align=center><input Author=meizz type=button value=今天 onclick="meizzToday()" ');
    document.writeln('             onfocus="this.blur()" title="转到今天的日期" style="font-size: 12px; height: 20px"></td><td ');
    document.writeln('             Author=meizz align=right><input Author=meizz type=button value=">" onclick="meizzNextM()" ');
    document.writeln('             onfocus="this.blur()" title="往后翻 月" style="font-size: 12px; height: 20px"><input ');
    document.writeln('             Author=meizz type=button value=">>" title="往后翻 年" onclick="meizzNextY()"');
    document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"></td>');
    document.writeln('</tr></table></td></tr></table>'); 
    document.writeln('<iframe style="position:absolute; visibility:inherit; top:0px; left:0px; width:142; height:166; z-index:-1; "></iframe>'); 
    document.writeln('</div>'); //==================================================== WEB 页面显示部分 ======================================================
    var outObject;
    function setday(tt,obj) //主调函数
    {
      if (arguments.length >  2){alert("对不起!传入本控件的参数太多!");return;}
      if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
      var dads  = document.all.meizzDateLayer.style;var th = tt;
      var ttop  = tt.offsetTop;     //TT控件的定位点高
      var thei  = tt.clientHeight;  //TT控件本身的高
      var tleft = tt.offsetLeft;    //TT控件的定位点宽
      var ttyp  = tt.type;          //TT控件的类型
      while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
      dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
      dads.left = tleft;
      outObject = (arguments.length == 1) ? th : obj;
      dads.display = '';
      event.returnValue=false;
    } var MonHead = new Array(12);               //定义阳历中每个月的最大天数
        MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4]  = 31; MonHead[5]  = 30;
        MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31; var meizzTheYear=new Date().getFullYear(); //定义年的变量的初始值
    var meizzTheMonth=new Date().getMonth()+1; //定义月的变量的初始值
    var meizzWDay=new Array(37);               //定义写日期的数组 function document.onclick() //任意点击时关闭该控件

      with(window.event.srcElement)
      { if (tagName != "INPUT" && getAttribute("Author")==null)
        document.all.meizzDateLayer.style.display="none";
      }
    }
      

  16.   

    function meizzWriteHead(yy,mm)  //往 head 中写入当前的年与月
      { document.all.meizzYearHead.innerText  = yy;
        document.all.meizzMonthHead.innerText = mm;
      } function tmpSelectYearInnerHTML(strYear) //年份的下拉框
    {
      if (strYear.match(/\D/)!=null){alert("年份输入参数不是数字!");return;}
      var m = (strYear) ? strYear : new Date().getFullYear();
      if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
      var n = m - 10;
      if (n < 1000) n = 1000;
      if (n + 26 > 9999) n = 9974;
      var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
         s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
         s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
         s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
      var selectInnerHTML = s;
      for (var i = n; i < n + 26; i++)
      {
        if (i == m)
           {selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";}
        else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";}
      }
      selectInnerHTML += "</select>";
      document.all.tmpSelectYearLayer.style.display="";
      document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
      document.all.tmpSelectYear.focus();
    } function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
    {
      if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
      var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
      var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
         s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' "
         s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";"
         s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
      var selectInnerHTML = s;
      for (var i = 1; i < 13; i++)
      {
        if (i == m)
           {selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>\r\n";}
        else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>\r\n";}
      }
      selectInnerHTML += "</select>";
      document.all.tmpSelectMonthLayer.style.display="";
      document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
      document.all.tmpSelectMonth.focus();
    } function closeLayer()               //这个层的关闭
      {
        document.all.meizzDateLayer.style.display="none";
      } function document.onkeydown()
      {
        if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none";
      } function IsPinYear(year)            //判断是否闰平年
      {
        if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
      } function GetMonthCount(year,month)  //闰年二月为29天
      {
        var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
      } function GetDOW(day,month,year)     //求某天的星期几
      {
        var dt=new Date(year,month-1,day).getDay()/7; return dt;
      } function meizzPrevY()  //往前翻 Year
      {
        if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
        else{alert("年份超出范围(1000-9999)!");}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzNextY()  //往后翻 Year
      {
        if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
        else{alert("年份超出范围(1000-9999)!");}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzToday()  //Today Button
      {
        meizzTheYear = new Date().getFullYear();
        meizzTheMonth = new Date().getMonth()+1;
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzPrevM()  //往前翻月份
      {
        if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzNextM()  //往后翻月份
      {
        if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      } function meizzSetDay(yy,mm)   //主要的写程序**********
    {
      meizzWriteHead(yy,mm);
      for (var i = 0; i < 37; i++){meizzWDay[i]=""};  //将显示框的内容全部清空
      var day1 = 1,firstday = new Date(yy,mm-1,1).getDay();  //某月第一天的星期几
      for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
      for (var i = 0; i < 37; i++)
      { var da = eval("document.all.meizzDay"+i)     //书写新的一个月的日期星期排列
        if (meizzWDay[i]!="")
          { da.innerHTML = "<b>" + meizzWDay[i] + "</b>";
            da.style.backgroundColor = (yy == new Date().getFullYear() &&
            mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
            da.style.cursor="hand"
          }
        else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
      }
    }
    function meizzDayClick(n)  //点击显示框选取日期,主输入函数*************
    {
      var yy = meizzTheYear;
      var mm = meizzTheMonth;
      if (mm < 10){mm = "0" + mm;}
      if (outObject)
      {
        if (!n) {outObject.value=""; return;}
        if ( n < 10){n = "0" + n;}
        outObject.value= yy + "-" + mm + "-" + n ; //注:在这里你可以输出改成你想要的格式
        closeLayer(); 
      }
      else {closeLayer(); alert("您所要输出的控件对象并不存在!");}
    }
    meizzSetDay(meizzTheYear,meizzTheMonth);
    // -->
    </script>
    选择日期:<input name="date"  onfocus="setday(this)" size="9" maxlength="10">
    得到星期:<input name="date"  size="9" maxlength="10">
    怎樣得到星期与日期相对应!!!!!!
      

  17.   

    <script language=javascript>
    <!--
    document.writeln('<div id=meizzDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
    document.writeln('<span id=tmpSelectYearLayer  style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
    document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
    document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#808080 onselectstart="return false">');
    document.writeln('  <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
    document.writeln('      <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
    document.writeln('        onclick="meizzPrevM()" title="向前翻 月" Author=meizz><b Author=meizz>&lt;&lt;</b>');
    document.writeln('        </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
    document.writeln('        <span Author=meizz id=meizzYearHead onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
    document.writeln('         id=meizzMonthHead Author=meizz onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
    document.writeln('        <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
    document.writeln('         onclick="meizzNextM()" title="往后翻 月" Author=meizz><b Author=meizz>&gt;&gt;</b></td></tr>');
    document.writeln('    </table></td></tr>');
    document.writeln('  <tr><td width=142 height=18 bgcolor=#808080>');
    document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
    document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>');
    document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>');
    document.writeln('</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: [email protected] 2002-10-8 -->');
    document.writeln('  <tr><td width=142 height=120>');
    document.writeln('    <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF>');
    var n=0; for (j=0;j<5;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
    document.writeln('<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=meizzDayClick(this.innerText)></td>');n++;}
    document.writeln('</tr>');}
    document.writeln('      <tr align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
    document.writeln('         onclick=meizzDayClick(this.innerText)></td>');
    document.writeln('        <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz onclick=meizzDayClick(this.innerText)></td></tr>');
    document.writeln('    </table></td></tr><tr><td>');
    document.writeln('        <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
    document.writeln('          <tr><td Author=meizz align=left><input Author=meizz type=button value="<<" title="向前翻 年" onclick="meizzPrevY()" ');
    document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"><input Author=meizz title="向前翻 月" type=button ');
    document.writeln('             value="<" onclick="meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td><td ');
    document.writeln('             Author=meizz align=center><input Author=meizz type=button value=今天 onclick="meizzToday()" ');
    document.writeln('             onfocus="this.blur()" title="转到今天的日期" style="font-size: 12px; height: 20px"></td><td ');
    document.writeln('             Author=meizz align=right><input Author=meizz type=button value=">" onclick="meizzNextM()" ');
    document.writeln('             onfocus="this.blur()" title="往后翻 月" style="font-size: 12px; height: 20px"><input ');
    document.writeln('             Author=meizz type=button value=">>" title="往后翻 年" onclick="meizzNextY()"');
    document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"></td>');
    document.writeln('</tr></table></td></tr></table>'); 
    document.writeln('<iframe style="position:absolute; visibility:inherit; top:0px; left:0px; width:142; height:166; z-index:-1; "></iframe>'); 
    document.writeln('</div>'); //==================================================== WEB 页面显示部分 ======================================================
    var outObject;
    function setday(tt,obj) //主调函数
    {
      if (arguments.length >  2){alert("对不起!传入本控件的参数太多!");return;}
      if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
      var dads  = document.all.meizzDateLayer.style;var th = tt;
      var ttop  = tt.offsetTop;     //TT控件的定位点高
      var thei  = tt.clientHeight;  //TT控件本身的高
      var tleft = tt.offsetLeft;    //TT控件的定位点宽
      var ttyp  = tt.type;          //TT控件的类型
      while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
      dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
      dads.left = tleft;
      outObject = (arguments.length == 1) ? th : obj;
      dads.display = '';
      event.returnValue=false;
    } var MonHead = new Array(12);               //定义阳历中每个月的最大天数
        MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4]  = 31; MonHead[5]  = 30;
        MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31; var meizzTheYear=new Date().getFullYear(); //定义年的变量的初始值
    var meizzTheMonth=new Date().getMonth()+1; //定义月的变量的初始值
    var meizzWDay=new Array(37);               //定义写日期的数组 function document.onclick() //任意点击时关闭该控件

      with(window.event.srcElement)
      { if (tagName != "INPUT" && getAttribute("Author")==null)
        document.all.meizzDateLayer.style.display="none";
      }
    }
      

  18.   


    function meizzWriteHead(yy,mm)  //往 head 中写入当前的年与月
      { document.all.meizzYearHead.innerText  = yy;
        document.all.meizzMonthHead.innerText = mm;
      } function tmpSelectYearInnerHTML(strYear) //年份的下拉框
    {
      if (strYear.match(/\D/)!=null){alert("年份输入参数不是数字!");return;}
      var m = (strYear) ? strYear : new Date().getFullYear();
      if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
      var n = m - 10;
      if (n < 1000) n = 1000;
      if (n + 26 > 9999) n = 9974;
      var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
         s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
         s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
         s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
      var selectInnerHTML = s;
      for (var i = n; i < n + 26; i++)
      {
        if (i == m)
           {selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";}
        else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";}
      }
      selectInnerHTML += "</select>";
      document.all.tmpSelectYearLayer.style.display="";
      document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
      document.all.tmpSelectYear.focus();
    } function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
    {
      if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
      var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
      var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
         s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' "
         s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";"
         s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
      var selectInnerHTML = s;
      for (var i = 1; i < 13; i++)
      {
        if (i == m)
           {selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>\r\n";}
        else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>\r\n";}
      }
      selectInnerHTML += "</select>";
      document.all.tmpSelectMonthLayer.style.display="";
      document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
      document.all.tmpSelectMonth.focus();
    } function closeLayer()               //这个层的关闭
      {
        document.all.meizzDateLayer.style.display="none";
      } function document.onkeydown()
      {
        if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none";
      } function IsPinYear(year)            //判断是否闰平年
      {
        if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
      } function GetMonthCount(year,month)  //闰年二月为29天
      {
        var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
      } function GetDOW(day,month,year)     //求某天的星期几
      {
        var dt=new Date(year,month-1,day).getDay()/7; return dt;
      } function meizzPrevY()  //往前翻 Year
      {
        if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
        else{alert("年份超出范围(1000-9999)!");}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzNextY()  //往后翻 Year
      {
        if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
        else{alert("年份超出范围(1000-9999)!");}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzToday()  //Today Button
      {
        meizzTheYear = new Date().getFullYear();
        meizzTheMonth = new Date().getMonth()+1;
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzPrevM()  //往前翻月份
      {
        if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      }
    function meizzNextM()  //往后翻月份
      {
        if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
        meizzSetDay(meizzTheYear,meizzTheMonth);
      } function meizzSetDay(yy,mm)   //主要的写程序**********
    {
      meizzWriteHead(yy,mm);
      for (var i = 0; i < 37; i++){meizzWDay[i]=""};  //将显示框的内容全部清空
      var day1 = 1,firstday = new Date(yy,mm-1,1).getDay();  //某月第一天的星期几
      for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
      for (var i = 0; i < 37; i++)
      { var da = eval("document.all.meizzDay"+i)     //书写新的一个月的日期星期排列
        if (meizzWDay[i]!="")
          { da.innerHTML = "<b>" + meizzWDay[i] + "</b>";
            da.style.backgroundColor = (yy == new Date().getFullYear() &&
            mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
            da.style.cursor="hand"
          }
        else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
      }
    }
    function meizzDayClick(n)  //点击显示框选取日期,主输入函数*************
    {
      var yy = meizzTheYear;
      var mm = meizzTheMonth;
      if (mm < 10){mm = "0" + mm;}
      if (outObject)
      {
        if (!n) {outObject.value=""; return;}
        if ( n < 10){n = "0" + n;}
        outObject.value= yy + "-" + mm + "-" + n ; //注:在这里你可以输出改成你想要的格式
        closeLayer(); 
      }
      else {closeLayer(); alert("您所要输出的控件对象并不存在!");}
    GetWeekday();
    }function GetWeekday()
    {
    var arrInput = document.getElementById("date").value.split("-");
    var d = new Date(arrInput[0], arrInput[1] - 1, arrInput[2]);
    document.getElementById("week").value = "星期"+"日一二三四五六".charAt(d.getDay());
    }
    meizzSetDay(meizzTheYear,meizzTheMonth);// -->
    </script>
    选择日期:<input name="date"  onfocus="setday(this)" size="9" maxlength="10" onkeyup="GetWeekday()">
    得到星期:<input name="week"  size="9" maxlength="10">