input 日期选择功能的javascript代码
document.writeln('
');
document.writeln(' ');
document.writeln(' ');
document.writeln('
'); document.writeln('
'); |
|||||||
'); document.writeln('
'); |
|||||||
'); document.writeln(' '); |
|||||||
'); document.writeln('
'); |
');
document.writeln('');
document.writeln('
');
document.writeln('');
document.writeln('.FlatButton {background-color: #f0f0f0; color: #000000;font-family:宋体;');
document.writeln(' font-size: 12px;position:relative;width:64px;height:20px;valign:top;cursor:hand;');
document.writeln(' border-left: 1px solid #DDDDDD; border-right: 1px solid #999999; ');
document.writeln(' border-top: 1px solid #DDDDDD; border-bottom: 1px solid #999999 ;');
document.writeln(' }');
document.writeln(' .FlatButton2 {background-color: #f0f0f0; color: #000000;font-family:宋体;');
document.writeln(' font-size: 12px;position:relative;height:20px;valign:top;cursor:hand;');
document.writeln(' border-left: 1px solid #DDDDDD; border-right: 1px solid #999999; ');
document.writeln(' border-top: 1px solid #DDDDDD; border-bottom: 1px solid #999999 ;');
document.writeln(' }');
document.writeln('');
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";
//add on 2004-9-7
//begin
if (document.getElementsByTagName("select"))
{
var obj;
obj=document.getElementsByTagName("select");
for (i=0;i 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
var n = m - 10;
if (n 9999) n = 9974;
var s = "\r\n";
var selectInnerHTML = s;
selectInnerHTML += "" + "..." + "\r\n";
for (var i = n; i " + i + "年" + "\r\n";}
else {selectInnerHTML += "" + i + "年" + "\r\n";}
}
selectInnerHTML += "" + "..." + "\r\n";
selectInnerHTML += "";
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 = "\r\n";
var selectInnerHTML = s;
for (var i = 1; i "+i+"月"+"\r\n";}
else {selectInnerHTML += ""+i+"月"+"\r\n";}
}
selectInnerHTML += "";
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 999 && meizzTheYear 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 " + meizzWDay[i] + "";
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
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]