document.writeln ('<select onchange="selectdate(0,this.value)" style="border:none;">')
document.writeln ('<option value="'+new date().getyear()+'" selected>'+new date().getyear()+'</option>')
for (y=new date().getyear()-10;y<=new date().getyear()+10;y++){
//此处可以修改选择日期的开始与结束年份
document.writeln ('<option value='+y+'>'+y+'</option>')
}
document.writeln ('</select>年<select onchange="selectdate(1,this.value)">')
document.writeln ('<option value="'+new date().getmonth()+'" selected>'+(new date().getmonth()+1)+'</option>')
for (m=1;m<=12;m++){
//此处可以修改选择日期的开始与结束年份
document.writeln ('<option value='+m+'>'+m+'</option>')
}
document.writeln ('<select> 月 <span style="cursor:hand" onclick="opencell(0)" title="关闭时间选择器">关闭</span>')
document.writeln ('</td></tr></table></div>')
//到此日期层结束
//关闭日期层的层
document.writeln ('<div id=closedatelayer style="display:none;left:0;top:0;position:absolute;width:110;height:10;z-index:99;font-size:12px"><span style="cursor:hand" onclick="opencell(1)" title="打开时间选择器">选择 </span><span style="cursor:hand" onclick="closelayer()">关闭窗口 </span><span onclick="about(1)" style="cursor:hand" title="关于本程序">关于</span></div>')
var tobject//全局变量,对象
var year//年
var month//月
var thedate//日
var datestyle//日期样式
var lack
function setdate(obj,aspect){//算日期
//obj 0=年,1=ā月 aspect 0=减 1=加
month=document.all.month.innertext//月,表格里的
year=document.all.year.innertext//年
if (month=="") month=new date().getmonth()+1;//如果时间为空,则为当前年月
if (year=="") year=new date().getyear();
//=====================================
if (obj==0){//年
if (aspect==0){//减
year=year-1;
}else{
year=year*1+1;
}
}else if (obj==1){
if (aspect==0){
month=month-1;
}else{
month=month*1+1;
}
}
if (month==13){//大于12月
year=year*1+1;
month=1;
}
if (month==0){//小于1月
year=year-1;
month=12;
}
writedate(year,month)
}
//======================================
function selectdate(selectobject,value){
//selectobject 0为年,1为月
if (selectobject==0){
year=value
writedate(value,month)
}else if (selectobject==1){
month=value
writedate(year,value)
}
}
//====================================
function writedate(writeyear,writemonth){//写入年与日历
var day
var firstday
if (writemonth==1||writemonth==3||writemonth==5||writemonth==7||writemonth==8||writemonth==10||writemonth==12){
day=31//大月
}else if(writemonth==4||writemonth==6||writemonth==9||writemonth==11){
day=30//小月
}else if (writeyear%4==0&&(writeyear%100!==0||writeyear%500==0)){
day=29
}else{
day=28
}
firstday=new date(writeyear,writemonth-1,1).getday();
firstday=0-firstday
//本月第一天是星期几
var u=firstday+1;
for (f=0;f<=41;f++){
var thisday = eval("document.all.day"+f)
//====================================小于1则为空
if (u<1||u>day){
thisday.innerhtml=" ";
thisday.style.cursor="default";
thisday.bgcolor="#ffffff";
}else{
thisday.innerhtml=u
thisday.bgcolor="#e6ecff";
}
//=====================================
u++;
}
document.all.year.innerhtml=writeyear;//写入年
document.all.month.innerhtml=writemonth;//写入月
var year_month
if (tobject.value==""){//初始值
year_month=evaldate(writeyear,writemonth,new date().getdate())
}else{
if (thedate="undefined"){
thedate=new date().getdate()
tobject.value=tobject.value //没有选择日期
}
year_month=evaldate(writeyear,writemonth,thedate)
}
//tobject.value=year_month;
//计算一个月多少天结束
}
//==============================================
function evaldate(theyear,themonth,theday){//计算日期与样式
//lack (=0 补0;lack=1 不补0;);styledate(=0 -;=1 /;=2 汉字日期;=3 yymmdd )
if (lack==0){//补0
if (themonth<10){themonth="0"+themonth};
if (theday<10) {theday="0"+theday};
}
if (datestyle==0){
return theyear+"-"+themonth+"-"+theday
}else if (datestyle==1){
return theyear+"/"+themonth+"/"+theday
}else if (datestyle==2){
return theyear+"年"+themonth+"月"+theday+"日"
}else{