<form id=f>
年<SELECT id=s1 name=s1 onchange="vbs:aaa"></SELECT>
月<SELECT id=s2 name=s2 onchange="vbs:aaa"></SELECT>
日<SELECT id=s3 name=s3></SELECT>
</form>
<SCRIPT LANGUAGE=vbscript>
'初始年
MyAdd "f.s1",1970,2050
'初始月
MyAdd "f.s2",1,12
'初始日
MyAdd "f.s3",1,31
sub MyAdd(S,x,y)'增加
set obj=eval(S)
for i=x to y
set o=document.createElement("OPTION")
o.text=i
o.value=i
obj.add o
next
end sub
sub MyRemove(S)'删除
set obj=eval(S)
for each opt in obj.options
obj.remove opt.index
next
end sub
sub aaa'自定义过程,用来改变s3日期
dim mydate,maxdate
'先清空全部,最好从28号以后清空,但是这样效率低人感觉不到,偷点懒不是罪
MyRemove "f.s3"
for i=1 to 31
mydate=f.s1.value & "-" & f.s2.value & "-" & i
if isdate(mydate) then '判断是否是有效日期
maxdate=i
else
exit for
end if
next
MyAdd "f.s3",1,maxdate
end sub
</SCRIPT>
<script language="JavaScript">
function initDate() {
var obj=document.all['dateform'];
var y=obj.year;
var m=obj.month;
var d=obj.date;
for (var i=1900;i<2004;i++) {
y.options.length=y.options.length+1;
y.options[y.options.length-1].text=y[y.options.length-1].value=i;
}
y.value=1978;
for (var i=0;i<12;i++) {
m.options.length=i+1;
m[i].value=i+1;
if (i<9) {
m.options[i].text="0"+(i+1);
} else {
m.options[i].text=i+1;
}
}
m.value=1;
for (var i=0;i<31;i++) {
d.options.length=i+1;
d[i].value=i+1;
if (i<9) {
d.options[i].text="0"+(i+1);
} else {
d.options[i].text=i+1;
}
}
d.value=1;
}
function setDate(obj) {
var y=obj.year.value;
var m=obj.month.value;
var d=obj.date;
var arrd=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if (y%4==0) arrd[1]=29;
var md=arrd[m-1];
if (d.options.length>md) {
var index=d.value;
d.options.length=md;
if (index<md) {
d.value=index;
} else {
d.value=md;
}
}
if (d.options.length<md) {
for (var i=d.options.length;i<md;i++) {
d.options.length=d.options.length+1;
d[i].value=d.options[i].text=i+1;
}
}
}
</script>
<body onLoad="initDate()">
<form name="dateform">
<select name="year" onChange="setDate(this.form)"></select>年
<select name="month" onChange="setDate(this.form)"></select>月
<select name="date"></select>日
</form>
</body>
http://search.csdn.net/Expert/topic/2537/2537402.xml?temp=.4333917
http://www.adr.gov.cn/summit/statistics/DanWtj.asp
GB数据库
下载