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('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

<');
document.writeln('
');
document.writeln('  年  月
>

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
var n=0;for (j=0;j');
for (i=0;i

');n++;}
document.writeln('

');}
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

');
document.writeln('

" onclick="meizzNextM()" onfocus="this.blur()"');
document.writeln(' title="往后翻月" class="FlatButton2" ID="Button3" NAME="Button3">>" title="往后翻年" onclick="meizzNextY()" onfocus="this.blur()"');
document.writeln(' class="FlatButton2" ID="Button4" NAME="Button4">

');
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需刷新才能执行]

(0)

相关推荐

  • javascript实现日期三级联动下拉框选择菜单

    由于工作中涉及到生日编辑资料编辑,年月日用上面网址案例:bug提示: 编辑生日栏的[年]或者[月],之前保存的具体的[日]就不显示啦,产品说不管编辑哪个数据,其他数据不变: 然后自己改了一下代码: <html> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width,initial-scale=1,minimu

  • js简单的年月联动实现代码

    HTML 复制代码 代码如下: <SELECT NAME="SelTjYear"> </SELECT> <SELECT NAME="SelTjMonth"> </SELECT> 源码: 复制代码 代码如下: function vYearMonth(yearObjId, monthObjId) { var selYear = document.getElementById(yearObjId); var selMonth

  • 实现一个年、月、季度联动SELECT的javascript代码

    请选择报告类型 月度报告 季度报告 半年报告 年度报告 function GetValue(){ var objlist = document.getElementsByTagName("SELECT"); var tmp = new Array(); var tap = objlist[0].options[objlist[0].selectedIndex].text; strTmp=""; var j = 1; for(var i=1;i0){ select.o

  • javascript英文日期(有时间)选择器

    var languageCode = 'en';    // Possible values:     en,ge,no,nl,es,pt-br,fr                                 // en = english, ge = german, no = norwegian,nl = dutch, es = spanish, pt-br = portuguese, fr = french, da = danish, hu = hungarian(Use UTF-8 

  • javascript 表单日期选择效果

    Agenda BODY { FONT-SIZE: 9pt; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; } A { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000 } A:hover { TEXT-DECORATION: none; color: #000000 } A:link { TEXT-DEC

  • js实现年月日表单三级联动

    用Html实现人人网注册界面 ,Js实现生日栏表单三级联动 1. 效果 2.Html代码部分 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>人人网日期表单联动</title> <style> select { font:20px/40px '宋体'; } option {width: 100

  • JS日期和时间选择控件升级版(自写)

    鉴于网上找到的几个日期选择程序有些问题,遂着手重写一个程序,大部分还是借鉴前人的代码,添加了时间选择功能,隐藏会遮挡控件的标签select,object. 开始本想使用window.createPopup()来弹出日历的选择,这样就可以跨过任何标签. 不过做到中途发现用createPopup窗口实现理论上是行不通的: 一是因为不在窗体里单击任何地方都会关闭窗口,而当用下拉框选择年份时,很有可能会单击到窗体外的地方,当然这个可以自己写select来避免,但是比较麻烦: 二是窗体的宽度和高度只能在弹

  • javascript 09年最新版的省市联动

    请选择 请选择 请选择 var areaData = "110000|北京市,110100|市辖区,110101|东城区,110102|西城区,110103|崇文区,110104|宣武区,110105|朝阳区,110106|丰台区,110107|石景山区,110108|海淀区,110109|门头沟区,110111|房山区,110112|通州区,110113|顺义区,110114|昌平区,110115|大兴区,110116|怀柔区,110117|平谷区,110200|县,110228|密云县,11

  • javascript 年月日联动实现核心代码

    复制代码 代码如下: var StartYear = 1980; var EndYear = 2500; function MonthAndDay() { this.initDDL = function(objYear,objMonth,objDay,hidYear,hidMonth,hidDay) { this.init(objYear,objMonth,objDay,hidYear,hidMonth,hidDay); this.SelectChange(objYear,objMonth,ob

  • js选择日期

    var DS_x,DS_y; function dateSelector() //构造dateSelector对象,用来实现一个日历形式的日期输入框. { var myDate=new Date(); this.year=myDate.getYear(); //定义year属性,年份,默认值为当前系统年份. this.month=myDate.getMonth()+1; //定义month属性,月份,默认值为当前系统月份. this.date=myDate.getDate(); //定义date

随机推荐