写它一个日期控件

<!--
//-------------------------------------------------------------------------------

// 这是我做的一个日历 Javascript 页面脚本控件,适用于微软的 IE (5.5以上)浏览器
// 主调用函数是 setday(this)是控件输出的控件名,举两个具体调用的例子:
// 一、<input name=txt><input type=button value=setday οnclick="setday(this)">
// 二、<input οnfοcus="setday(this)">
// 若有什么不足的地方,或者您有更好的建议,
// 本日历的年份限制是(1000 - 9999)

//==================================================== WEB 页面显示部分 =====================================================

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"><select id=tmpSelectYear ></select></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"><select id=tmpSelectMonth ><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option></select></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 id=prevm align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' οnclick="meizzPrevM()" title="向前翻 月" Author=meizz><b Author=meizz><<</b>');
document.writeln(' </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
document.writeln(' <span Author=meizz id=meizzYearHead οnclick="tmpSelectYearInnerHTML(this.innerText)"></span> 年 <span');
document.writeln(' id=meizzMonthHead Author=meizz οnclick="tmpSelectMonthInnerHTML(this.innerText)"></span> 月</td>');
document.writeln(' <td width=20 bgcolor=#808080 id=nextm align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' οnclick="meizzNextM()" title="往后翻 月" Author=meizz><b Author=meizz>>></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: meizz@hzcnc.com 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 οnclick=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(' οnclick=meizzDayClick(this.innerText)></td>');
document.writeln(' <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz οnclick=meizzDayClick(this.innerText)>111</td>');
document.writeln(' <td colspan=5 align=right Author=meizz><span style="font-size:12px;cursor: hand"');
document.writeln(' Author=meizz title="作者: F.R.Huang(meizz)
MAIL: meizz@hzcnc.com"><u id=clsdate>清除日期</u> <u id=closm>关闭</u></span> </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 id=prevyear type=button value="< " title="向前翻 年" οnclick="meizzPrevY()" ');
document.writeln(' οnfοcus="this.blur()" style="font-size: 12px; height: 20px"><input id=prevm1 Author=meizz title="向前翻 月" type=button ');
document.writeln(' value="<<" οnclick="meizzPrevM()" οnfοcus="this.blur()" style="font-size: 12px; height: 20px"></td><td ');
document.writeln(' Author=meizz align=center><input Author=meizz type=button id=today value=今天 οnclick="meizzToday()" ');
document.writeln(' οnfοcus="this.blur()" title="现在的年月" style="font-size: 12px; height: 20px"></td><td ');
document.writeln(' Author=meizz align=right><input Author=meizz type=button value=">>" id=nextm1 οnclick="meizzNextM()" ');
document.writeln(' οnfοcus="this.blur()" title="往后翻 月" style="font-size: 12px; height: 20px"><input ');
document.writeln(' Author=meizz id=nextyear type=button value=" >" title="往后翻 年" οnclick="meizzNextY()"');
document.writeln(' οnfοcus="this.blur()" style="font-size: 12px; height: 20px"></td>');
document.writeln('</tr></td></tr></table></div>');
//==================================================== WEB 页面显示部分 ======================================================


var oPopup;
var outObject;
function window.onload()
{
try
{
window.createPopup()
}
catch(e)
{
return;
}
oPopup = window.createPopup();
oPopup.document.body.innerHTML = meizzDateLayer.innerHTML;
oPopup.document.all.closm.οnclick=function(){closeLayer()}
oPopup.document.all.clsdate.οnclick=function(){cleardate(); closeLayer()}
oPopup.document.all.prevm.οnclick=function(){meizzPrevM()}
oPopup.document.all.prevm1.οnclick=function(){meizzPrevM()}
oPopup.document.all.nextm.οnclick=function(){meizzNextM()}
oPopup.document.all.nextm1.οnclick=function(){meizzNextM()}
for (var i = 0; i < 37; i++)
{ var da = eval("oPopup.document.all.meizzDay"+i)
da.οnclick=function(){meizzDayClick(this.innerText)}
}
oPopup.document.all.prevyear.οnclick=function(){meizzPrevY()}
oPopup.document.all.nextyear.οnclick=function(){meizzNextY()}
oPopup.document.all.today.οnclick=function(){meizzToday()}


oPopup.document.all.meizzYearHead.οnclick=function(){oPopup.document.all.tmpSelectYearLayer.style.display="block"}
oPopup.document.all.tmpSelectYear.οnblur=function(){oPopup.document.all.tmpSelectYearLayer.style.display="none"}
oPopup.document.all.tmpSelectYear.οnchange=function(){
//alert(this.options[this.selectedIndex].value);
tmpSelectYearInnerHTML();
meizzTheYear = this.options[this.selectedIndex].value; meizzSetDay(meizzTheYear,meizzTheMonth)
oPopup.document.all.tmpSelectYearLayer.style.display="none";
}

oPopup.document.all.meizzMonthHead.οnclick=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="block"}
oPopup.document.all.tmpSelectMonth.οnblur=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="none"}
oPopup.document.all.tmpSelectMonth.οnchange=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="none";
meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth) }


meizzSetDay(meizzTheYear,meizzTheMonth);


//oPopup.document.all.btn1.οnclick=function(){alert(oPopup.document.all.txt1.value) };
//document.οnkeypress=function(){oPopup.document.all.txt1.value += String.fromCharCode(event.keyCode) };
}

function showPopup(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;}
ttop -= document.body.scrollTop;

var topper = (ttyp=="image")? ttop+thei : ttop+thei+6;
var lefter = tleft;
// dads.display = '';
oPopup.show(lefter+2,topper, 142, 200, document.body);
outObject = (arguments.length == 1) ? th : obj;
event.returnValue=false;
}


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";
}
}
*/

function meizzWriteHead(yy,mm) //往 head 中写入当前的年与月
{

oPopup.document.all.meizzYearHead.innerText = yy;
oPopup.document.all.meizzMonthHead.innerText = mm;
}

function cleardate() {
outObject .value= "";
}

function tmpSelectYearInnerHTML() //年份的下拉框
{
/*
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 id=tmpSelectYear style='font-size: 12px' "
s += "οnblur='oPopup.document.all.tmpSelectYearLayer.style.display=\"none\"' "
s += "οnchange='oPopup.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>";
oPopup.document.all.tmpSelectYearLayer.style.display="";
oPopup.document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
// oPopup.document.all.tmpSelectYear.focus();
*/

oPopup.document.all.tmpSelectYearLayer.style.display="";
tt=oPopup.document.all.tmpSelectYear;

var x=tt.options[tt.options.length-1].value
if(tt.options[tt.options.length-1].value-tt.options[tt.selectedIndex].value<2)
{
for(j=0;j<3;j++)
{
var oOption =oPopup.document.createElement("OPTION");
oOption.text=++x
oOption.value=x
tt.add(oOption);
}
}
}

function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
{

if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select Author=meizz id=tmpSelectMonth style='font-size: 12px' "
s += "οnblur='oPopup.document.all.tmpSelectMonthLayer.style.display=\"none\"' "
s += "οnchange='function(){oPopup.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>";
oPopup.document.all.tmpSelectMonthLayer.style.display="";
oPopup.document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
oPopup.document.all.tmpSelectMonth.focus();
}

function closeLayer() //这个层的关闭
{

// alert("aaa");
oPopup.show(0,0,0,0,""); //关闭
//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("oPopup.document.all.meizzDay"+i) //书写新的一个月的日期星期排列
if(da)
{
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("您所要输出的控件对象并不存在!");}
}


var IEversion
try{
window.createPopup()
IEversion="5.5up"
}
catch(e)
{
IEversion="under5.5"
}

function setdate(src)
{
if(IEversion=="5.5up")
src.οnclick=function(){showPopup(this)}
else
src.οnclick=function(){openm(this)}
}


function addOption(src, txt, val)
{
e=document.createElement("OPTION");
e.value= val;
e.text= txt;
src.options.add(e);
//document.all.sl.options.add(e);
//document.all.sl.selectedIndex=document.all.sl.length-1;
}


//年份的选择从1900到当前的日期
thisdate=new Date();
thisYear=thisdate.getYear();
for(i=1900; i <=thisYear; i ++) {
addOption(tmpSelectYear, i, i);
}

-->
====================================================================
<!--
//-------------------------------------------------------------------------------

// 这是我做的一个日历 Javascript 页面脚本控件,适用于微软的 IE (5.5以上)浏览器
// 主调用函数是 setday(this)是控件输出的控件名,举两个具体调用的例子:
// 一、<input name=txt><input type=button value=setday οnclick="setday(this)">
// 二、<input οnfοcus="setday(this)">
// 若有什么不足的地方,或者您有更好的建议,请与我联系:mail: meizz@hzcnc.com 修改者: mail: tony_kee@126.com
// 本日历的年份限制是(1000 - 9999)

//==================================================== WEB 页面显示部分 =====================================================

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"><select id=tmpSelectYear ></select></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"><select id=tmpSelectMonth ><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option></select></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 id=prevm align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' οnclick="meizzPrevM()" title="向前翻 月" Author=meizz><b Author=meizz><<</b>');
document.writeln(' </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
document.writeln(' <span Author=meizz id=meizzYearHead οnclick="tmpSelectYearInnerHTML(this.innerText)"></span> 年 <span');
document.writeln(' id=meizzMonthHead Author=meizz οnclick="tmpSelectMonthInnerHTML(this.innerText)"></span> 月</td>');
document.writeln(' <td width=20 bgcolor=#808080 id=nextm align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' οnclick="meizzNextM()" title="往后翻 月" Author=meizz><b Author=meizz>>></b></td></tr>');
document.writeln(' </table></td></tr>');
document.writeln('<tr>');
document.writeln(' <td colspan=7 height=20 align=left Author=meizz><span style="font-size:12px;cursor: hand"');
document.writeln(' Author=meizz title="作者: F.R.Huang(meizz) MAIL: meizz@hzcnc.com">时<select id="hour" ></select>分<select id=minute></select> <u id=clsdate>清除</u></span></td></tr>');
document.writeln(' </td></tr><tr><td>');
document.writeln('</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: meizz@hzcnc.com 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 οnclick=meizzDayClick(this.innerText)></td>');n++;}
document.writeln('</tr>');
}
document.writeln('<tr style=\"display:none\" align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
document.writeln(' οnclick=meizzDayClick(this.innerText) bgcolor=black></td>');
document.writeln(' <td width=20 colspan=6 height=20 style="font-size:12px" id=meizzDay36 Author=meizz οnclick=meizzDayClick(this.innerText) bgcolor=red></td>');
document.writeln('</tr>');

document.writeln('</table>');
document.writeln(' <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
document.writeln(' <tr><td Author=meizz align=left><input Author=meizz id=prevyear type=button value="< " title="向前翻 年" οnclick="meizzPrevY()" ');
document.writeln(' οnfοcus="this.blur()" style="font-size: 12px; height: 20px"><input id=prevm1 Author=meizz title="向前翻 月" type=button ');
document.writeln(' value="<<" οnclick="meizzPrevM()" οnfοcus="this.blur()" style="font-size: 12px; height: 20px"></td><td ');
document.writeln(' Author=meizz align=center><input Author=meizz type=button id=today value=今天 οnclick="meizzToday()" ');
document.writeln(' οnfοcus="this.blur()" title="现在的年月" style="font-size: 12px; height: 20px"></td><td ');
document.writeln(' Author=meizz align=right><input Author=meizz type=button value=">>" id=nextm1 οnclick="meizzNextM()" ');
document.writeln(' οnfοcus="this.blur()" title="往后翻 月" style="font-size: 12px; height: 20px"><input ');
document.writeln(' Author=meizz id=nextyear type=button value=" >" title="往后翻 年" οnclick="meizzNextY()"');
document.writeln(' οnfοcus="this.blur()" style="font-size: 12px; height: 20px"></td>');
document.writeln('</tr></td></tr></table></div>');
//==================================================== WEB 页面显示部分 ======================================================


var oPopup;
var outObject;
var popx,popy,popw,poph;
var yy = '2000';
var mm = '01';
var dd = '01';
var hour_value='00';
var minu_value='00';
function window.onload()
{
try
{
window.createPopup()

}
catch(e)
{
return;
}
oPopup = window.createPopup();

oPopup.document.body.innerHTML = meizzDateLayer.innerHTML;
// oPopup.document.all.closm.οnclick=function(){closeLayer()}
oPopup.document.all.clsdate.οnclick=function(){cleardate(); closeLayer()}
oPopup.document.all.prevm.οnclick=function(){meizzPrevM()}
oPopup.document.all.prevm1.οnclick=function(){meizzPrevM()}
oPopup.document.all.nextm.οnclick=function(){meizzNextM()}
oPopup.document.all.nextm1.οnclick=function(){meizzNextM()}
for (var i = 0; i < 37; i++)
{ var da = eval("oPopup.document.all.meizzDay"+i)
da.οnclick=function(){meizzDayClick(this.innerText)}
}
oPopup.document.all.prevyear.οnclick=function(){meizzPrevY()}
oPopup.document.all.nextyear.οnclick=function(){meizzNextY()}
oPopup.document.all.today.οnclick=function(){meizzToday()}


oPopup.document.all.meizzYearHead.οnclick=function(){oPopup.document.all.tmpSelectYearLayer.style.display="block"}
oPopup.document.all.tmpSelectYear.οnblur=function(){oPopup.document.all.tmpSelectYearLayer.style.display="none"}
oPopup.document.all.tmpSelectYear.οnchange=function(){
//alert(this.options[this.selectedIndex].value);
tmpSelectYearInnerHTML();
meizzTheYear = this.options[this.selectedIndex].value; meizzSetDay(meizzTheYear,meizzTheMonth)
oPopup.document.all.tmpSelectYearLayer.style.display="none";
}
//
oPopup.document.all.hour.οnchange=function() {
hour_value = this.options[this.selectedIndex].value;
outObject.value = getDate();
}

oPopup.document.all.minute.οnchange=function() {
minu_value = this.options[this.selectedIndex].value;
outObject.value = getDate();
}

oPopup.document.all.meizzMonthHead.οnclick=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="block"}
oPopup.document.all.tmpSelectMonth.οnblur=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="none"}
oPopup.document.all.tmpSelectMonth.οnchange=function(){oPopup.document.all.tmpSelectMonthLayer.style.display="none";
meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth) }


meizzSetDay(meizzTheYear,meizzTheMonth);


//oPopup.document.all.btn1.οnclick=function(){alert(oPopup.document.all.txt1.value) };
//document.οnkeypress=function(){oPopup.document.all.txt1.value += String.fromCharCode(event.keyCode) };
}


function showPopup(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;}
ttop -= document.body.scrollTop;

var topper = (ttyp=="image")? ttop+thei : ttop+thei+6;
var lefter = tleft;
// dads.display = '';
popx = lefter+2;
popy = topper;
popw = 142;
poph = 212;
oPopup.show(popx,popy, popw, poph, document.body);
outObject = (arguments.length == 1) ? th : obj;
event.returnValue=false;
}


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";
}
}
*/

function meizzWriteHead(yy,mm) //往 head 中写入当前的年与月
{

oPopup.document.all.meizzYearHead.innerText = yy;
oPopup.document.all.meizzMonthHead.innerText = mm;
}

function cleardate() {
outObject .value= "";
}

function tmpSelectYearInnerHTML() //年份的下拉框
{
/*
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 id=tmpSelectYear style='font-size: 12px' "
s += "οnblur='oPopup.document.all.tmpSelectYearLayer.style.display=\"none\"' "
s += "οnchange='oPopup.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>";
oPopup.document.all.tmpSelectYearLayer.style.display="";
oPopup.document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
// oPopup.document.all.tmpSelectYear.focus();
*/

oPopup.document.all.tmpSelectYearLayer.style.display="";
tt=oPopup.document.all.tmpSelectYear;

var x=tt.options[tt.options.length-1].value
if(tt.options[tt.options.length-1].value-tt.options[tt.selectedIndex].value<2)
{
for(j=0;j<3;j++)
{
var oOption =oPopup.document.createElement("OPTION");
oOption.text=++x
oOption.value=x
tt.add(oOption);
}
}
}


function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
{

if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select Author=meizz id=tmpSelectMonth style='font-size: 12px' "
s += "οnblur='oPopup.document.all.tmpSelectMonthLayer.style.display=\"none\"' "
s += "οnchange='function(){oPopup.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>";
oPopup.document.all.tmpSelectMonthLayer.style.display="";
oPopup.document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
oPopup.document.all.tmpSelectMonth.focus();


}

function closeLayer() //这个层的关闭
{
// alert("aaa");
//oPopup.show(0,0,0,0,""); //关闭
oPopup.hide();
//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("oPopup.document.all.meizzDay"+i) //书写新的一个月的日期星期排列
if(da)
{
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) //点击显示框选取日期,主输入函数*************
{
yy = meizzTheYear;
mm = meizzTheMonth;
if (mm < 10){mm = "0" + mm;}

if (outObject)
{
if (!n) {outObject.value=""; return;}
if ( n < 10){n = "0" + n;}
dd = n;
outObject.value= getDate(); //注:在这里你可以输出改成你想要的格式
// closeLayer();
}
else {closeLayer(); alert("您所要输出的控件对象并不存在!");}
}

function getDate() {
return yy + "/" + mm + "/" + dd + " " + hour_value + ":" + minu_value;
}


var IEversion
try{
window.createPopup()
IEversion="5.5up"
}
catch(e)
{
IEversion="under5.5"
}

function setdate(src)
{
if(IEversion=="5.5up")
src.οnclick=function(){showPopup(this)}
else
src.οnclick=function(){openm(this)}
}


function addOption(src, txt, val)
{
e=document.createElement("OPTION");
e.value= val;
e.text= txt;
src.options.add(e);
//document.all.sl.options.add(e);
//document.all.sl.selectedIndex=document.all.sl.length-1;
}


//年份的选择从1900到当前的日期
thisdate=new Date();
thisYear=thisdate.getYear();
for(i=1900; i <=thisYear; i ++) {
addOption(tmpSelectYear, i, i);
}

for(i=0; i <= 23; i ++) {
if(i < 10)
i = "0" + i;
addOption(hour, i, i);
}

for(i=0; i <= 59; i ++) {
if(i < 10)
i = "0" + i;
addOption(minute, i, i);
}


//function Click(){
//if(event.button==2){

//}
//alert(event.fromElement);
//window.status = event.srcElement;

//window.event.returnValue=false;
//if(popx > 0)
//oPopup.show(popx,popy, popw, poph, document.body);
//oPopup.document.event.returnValue =false;
//window.event.returnValue=false;
//}
//document.οnmοusedοwn=Click;
-->
===================================================================

<html>
<title></title>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<input type="text" name="t1" οnmοuseοver="setdate(this)">
<input type="text" name="t2" οnmοuseοver="setdate(this)"><br>
</body>
不想要时间,只要日期,请用setday.js<br>
要时间,也要日期,请用setdaytime.js<br>
<script src="setdaytime.js"></script>


<script>

</script>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值