复制代码 代码如下:
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,objDay,hidYear,hidMonth,hidDay);
}
this.init = function(objYear,objMonth,objDay,hidYear,hidMonth,hidDay)
{
var year = document.getElementById(objYear);
var month = document.getElementById(objMonth);
var day = document.getElementById(objDay);
var me=this;
if(year.length == 1)
{
year.options[0] = new Option("不限","");
for(var i = StartYear; i < EndYear; i++)
{
year.options[year.length] = new Option(i,i);
}
}
me.yearOptionsChange(document.all[objYear].value,objYear,objMonth,objDay);
me.monthOptionsChange(document.all[objYear].value,document.getElementById(objMonth).value,objDay);
}
this.yearOptionsChange = function(selectValue,objYear,objMonth,objDay)
{
var month = document.getElementById(objMonth);
var day = document.getElementById(objDay);
var me=this;
month.length = 0;
day.length = 0;
month.options[0]=new Option("不限",'');
day.options[0]=new Option("不限",'');
if(selectValue == "")
{
return ;
}
for(var i = 1; i < 13; i++)
{
month.options[month.length] = new Option((i < 10 ? ("0" + i) : i),i);
}
me.monthOptionsChange(document.getElementById(objYear).value,document.getElementById(objMonth).value,objDay);
}
this.monthOptionsChange = function(yearSelectValue,monthSelectValue,objDay)
{
var day = document.getElementById(objDay);
var endDay;
day.length = 0;
day.options[0]=new Option("不限",'');
if(monthSelectValue == "")
{
return;
}
if((parseInt(yearSelectValue) % 400 == 0) || (parseInt(yearSelectValue) % 4 == 0 && parseInt(yearSelectValue) % 100 != 0))
{
if(parseInt(monthSelectValue) == "2")
{
endDay = 29;
}
}
else
{
if(parseInt(monthSelectValue) == "2")
{
endDay = 28;
}
}
switch(parseInt(monthSelectValue))
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
endDay = 31;
break;
case 4:
case 6:
case 9:
case 11:
endDay = 30;
break;
}
for(var i = 1; i <= endDay; i++)
{
day.options[day.length] = new Option((i < 10 ? ("0" + i) : i),i);
}
}
this.SelectChange = function(objYear,objMonth,objDay,hidYear,hidMonth,hidDay)
{
var year = document.all[objYear];
var month = document.all[objMonth];
var day = document.all[objDay];
var me = this;
year.onchange = function()
{
me.yearOptionsChange(this.options[this.selectedIndex].value,objYear,objMonth,objDay);
document.all[hidYear].value = this.options[this.selectedIndex].value;
document.all[hidMonth].value = "";
document.all[hidDay].value = "";
}
month.onchange = function()
{
me.monthOptionsChange(document.all[hidYear].value,this.options[this.selectedIndex].value,objDay);
document.all[hidMonth].value = this.options[this.selectedIndex].value;
document.all[hidDay].value = "";
}
day.onchange = function()
{
document.all[hidDay].value = day.selectValue;
}
}
}
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,objDay,hidYear,hidMonth,hidDay);
}
this.init = function(objYear,objMonth,objDay,hidYear,hidMonth,hidDay)
{
var year = document.getElementById(objYear);
var month = document.getElementById(objMonth);
var day = document.getElementById(objDay);
var me=this;
if(year.length == 1)
{
year.options[0] = new Option("不限","");
for(var i = StartYear; i < EndYear; i++)
{
year.options[year.length] = new Option(i,i);
}
}
me.yearOptionsChange(document.all[objYear].value,objYear,objMonth,objDay);
me.monthOptionsChange(document.all[objYear].value,document.getElementById(objMonth).value,objDay);
}
this.yearOptionsChange = function(selectValue,objYear,objMonth,objDay)
{
var month = document.getElementById(objMonth);
var day = document.getElementById(objDay);
var me=this;
month.length = 0;
day.length = 0;
month.options[0]=new Option("不限",'');
day.options[0]=new Option("不限",'');
if(selectValue == "")
{
return ;
}
for(var i = 1; i < 13; i++)
{
month.options[month.length] = new Option((i < 10 ? ("0" + i) : i),i);
}
me.monthOptionsChange(document.getElementById(objYear).value,document.getElementById(objMonth).value,objDay);
}
this.monthOptionsChange = function(yearSelectValue,monthSelectValue,objDay)
{
var day = document.getElementById(objDay);
var endDay;
day.length = 0;
day.options[0]=new Option("不限",'');
if(monthSelectValue == "")
{
return;
}
if((parseInt(yearSelectValue) % 400 == 0) || (parseInt(yearSelectValue) % 4 == 0 && parseInt(yearSelectValue) % 100 != 0))
{
if(parseInt(monthSelectValue) == "2")
{
endDay = 29;
}
}
else
{
if(parseInt(monthSelectValue) == "2")
{
endDay = 28;
}
}
switch(parseInt(monthSelectValue))
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
endDay = 31;
break;
case 4:
case 6:
case 9:
case 11:
endDay = 30;
break;
}
for(var i = 1; i <= endDay; i++)
{
day.options[day.length] = new Option((i < 10 ? ("0" + i) : i),i);
}
}
this.SelectChange = function(objYear,objMonth,objDay,hidYear,hidMonth,hidDay)
{
var year = document.all[objYear];
var month = document.all[objMonth];
var day = document.all[objDay];
var me = this;
year.onchange = function()
{
me.yearOptionsChange(this.options[this.selectedIndex].value,objYear,objMonth,objDay);
document.all[hidYear].value = this.options[this.selectedIndex].value;
document.all[hidMonth].value = "";
document.all[hidDay].value = "";
}
month.onchange = function()
{
me.monthOptionsChange(document.all[hidYear].value,this.options[this.selectedIndex].value,objDay);
document.all[hidMonth].value = this.options[this.selectedIndex].value;
document.all[hidDay].value = "";
}
day.onchange = function()
{
document.all[hidDay].value = day.selectValue;
}
}
}
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“javascript 年月日联动实现核心代码”评论...
更新动态
2024年11月13日
2024年11月13日
- 刘欢《雨中的树(新歌加精选)2CD》德国HD24K金碟[WAV+CUE]
- 郑源 《世间情歌》6N纯银SQCD[WAV+CUE][1G]
- 群星《粤潮2HQII》头版限量编号[低速原抓WAV+CUE][991M]
- 群星《2023好听新歌21》十倍音质 U盘音乐[WAV分轨][1G]
- 《热血传奇》双11感恩回馈 超值狂欢30天
- 原神5.2版本活动汇总 5.2版本活动有哪些
- 张敬轩.2010-NO.ELEVEN【环球】【WAV+CUE】
- 黄丽玲.2006-失恋无罪【艾回】【WAV+CUE】
- 阿达娃.2024-Laluna【W8VES】【FLAC分轨】
- 宝可梦大集结段位等级划分表大全 大集结段位一览
- 龙腾世纪影障守护者工坊与装备如何升级 工坊与装备升级说明
- 龙腾世纪影障守护者全成就攻略分享 龙腾世纪4全成就列表一览
- 《剑星》更新四套全新战衣!
- 卡普空老将伊津野英昭宣布入职腾讯光子 开发3A动作
- 38岁梅根·福克斯官宣怀孕:将迎来第四个孩子