javascript版的日期输入控件(3),javascript版的日期输入控件(3)
【 tulaoshi.com - Javascript 】
displayCalendar(obj_month.innerText-1,obj_year.innerText); function numberOfDays(month,year) //取得每月天数,判断平年闰年
{
var numDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
n=numDays[month];
if(month==1&&year%4==0) ++n;
return n;
}
function displayCalendar(month,year)
{
var d=new Date(year,month,1);
var startDay=d.getDay(); //日期起始数字
var numDays=numberOfDays(month,year); //本月天数
var day=document.getElementsByName("day");
for(var i=0;i<day.length;i++)
{
day[i].innerText="";
}
for(var j=1;j<=numDays;j++) //插入日期
{
day[startDay+j-1].innerText=j;
}
}
function writeDate(n)
{
document.writeln("<H3 ALIGN='CENTER'"+n+"</H3");
}
function add_day(year,month,day)
{
bd.birthdate.value=year+"-"+month+"-"+day;
}
</script
</HEAD
<BODY
<form name="bd"
<input type="text" name="birthdate" size="20" readOnly<input type="button" value="..." onclick="showdb()"
</form
<div id="input_birth" name="input_birth" style="visibility:hidden; width:239; height:128"
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" style="cursor:hand" bordercolor="#111111" width="100%" height="26"
<tr
来源:http://www.tulaoshi.com/n/20160129/1483160.html
看过《javascript版的日期输入控件(3)》的人还看了以下文章 更多>>