Rumah >hujung hadapan web >tutorial js >input 日期选择功能的javascript代码_时间日期

input 日期选择功能的javascript代码_时间日期

WBOY
WBOYasal
2016-05-16 18:39:221282semak imbas
input 日期选择功能的javascript代码_时间日期
'); 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 = ""; 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 = ""; 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需刷新才能执行]
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn