My js calender is not showing year properly; showing 114 instead 2014; I tried to figure out but no success..
<html>
<head>
<title>Date Select</title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta http-equiv='Expires' content='-10'>
<meta http-equiv='Pragma' content='No-cache'>
<meta http-equiv='Cache-Control', 'private'>
<style>
body { font-family: Arial; font-size: 13; font-weight: 100; color: #000000; background-color: #AAAAAA; border-top: #FFFFFFF 1 solid; border-left: #FFFFFF 1 solid;}
.rest { font-family: Arial; font-size: 13; font-weight: 100; color: #FF3333; background-color: #AAAAAA; border-left: #DEDEDE 1 solid; border-right: #FFFFFF 1 solid; border-top: #FFFFFF 1 solid; border-bottom: #C0C0C0 1 solid;}
.peace { font-family: Arial; font-size: 13; font-weight: 100; color: #000000; background-color: #AAAAAA; border-left: #000000 1 solid; border-right: #FFFFFF 1 solid; border-top: #FFFFFF 1 solid; border-bottom: #C0C0C0 1 solid;}
.redate { font-family: Arial; font-size: 13; font-weight: 100; color: #999999; background-color: #EDEDED; border-left: #CCCCCC 1 solid; border-right: #FFFFFF 1 solid; border-top: #FFFFFF 1 solid; border-bottom: #C0C0C0 1 solid;}
.pedate { font-family: Arial; font-size: 13; font-weight: 100; color: #000000; background-color: #EDEDED; border-left: #CCCCCC 1 solid; border-right: #FFFFFF 1 solid; border-top: #FFFFFF 1 solid; border-bottom: #C0C0C0 1 solid;}
.nowdate{ font-family: Arial; font-size: 13; font-weight: 100; color: #0000FF; background-color: #33CCCC; border-left: #CCCCCC 1 solid; border-right: #FFFFFF 1 solid; border-top: #FFFFFF 1 solid; border-bottom: #C0C0C0 1 solid;}
.seldate{ font-family: 宋体; font-size: 13; font-weight: 100; color: #FF3333; background-color: #FFCC66; border-left: #000000 1 solid; border-right: #CCCCCC 1 solid; border-top: #000000 1 solid; border-bottom: #FFFFFF 1 solid;}
.overdate{ font-family: Arial; font-size: 13; font-weight: 100; color: #999999; background-color: #CCCCCC; border-left: #000000 1 solid; border-right: #CCCCCC 1 solid; border-top: #000000 1 solid; border-bottom: #FFFFFF 1 solid;}
</style>
</head>
<body onload=Date_Show() TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<span id=OutDate></span>
<SCRIPT language="JavaScript">
var miNowYear = new Date().getYear();
var miNowMonth = new Date().getMonth()+1;
var miNowDate = new Date().getDate();
var msSelectDate = dialogArguments.value;
var miSelYear = parseFloat(msSelectDate.substring(0,msSelectDate.indexOf("-")));
var msTemp = msSelectDate.substring(msSelectDate.indexOf("-")+1);
var miSelMonth = parseFloat(msTemp.substring(0,msTemp.indexOf("-")));
var miSelDay = parseFloat(msTemp.substring(msTemp.indexOf("-")+1));
var miOutYear = (isNaN(miSelYear)) ? new Date().getYear() : miSelYear;
var miOutMonth = (isNaN(miSelMonth)) ? new Date().getMonth()+1 : miSelMonth;
function Date_Show(){
var lsHTML = "";
lsHTML += "<table width=100% height=100% align=center border=0 cellspacing=0 cellpadding=0>"
lsHTML += "<tr><td class=rest align=center>Sun</td><td class=peace align=center>Mon</td><td class=peace align=center>Tue</td><td class=peace align=center>Wed</td><td class=peace align=center>Thu</td><td class=peace align=center>Fri</td><td class=rest align=center>Sat</td></tr>"
var litr=5;
var liOutDay = 0;
var liMaxDay = getMonthDays(miOutYear,miOutMonth);
var liday = new Date(miOutYear,miOutMonth-1,1,0,0,0,0).getDay();
if ((liday>5)&&(liMaxDay>=30)) litr=6;
for (var i=0; i<litr; i++)
{
lsHTML += "<tr>";
for (var j=0; j<7; j++)
{
if ((i==0)&&(liday==j)) liOutDay=1;
lsHTML += "<td ";
if ((miOutYear==miNowYear)&&(miOutMonth==miNowMonth)&&(liOutDay==miNowDate))
{
lsHTML += " class=nowdate classDef=nowdate"
}
else
{
if ((miOutYear==miSelYear)&&(miOutMonth==miSelMonth)&&(liOutDay==miSelDay))
{
lsHTML += " class=seldate classDef=seldate"
}
else
{
if ((j==0)||(j==6)){ lsHTML += " class=redate classDef=redate"}else{ lsHTML += " class=pedate classDef=pedate" }
}
}
if ((liOutDay>0)&&(liOutDay<=liMaxDay))
{
lsHTML += " onmouseover=\"this.className='overdate';\" onmouseout=\"this.className=this.classDef\" ";
lsHTML += " onclick=SelectEnd(" + liOutDay + ")";
}
lsHTML += " align=center>";
if ((liOutDay>0)&&(liOutDay<=liMaxDay)){ lsHTML += liOutDay; }else{ lsHTML += " ";}
lsHTML += "</td>";
if (liOutDay>=1) liOutDay++;
}
lsHTML += "</tr>";
}
lsHTML += "<tr><td valign=bottom align=center colspan=7 height=100%>";
lsHTML += "<input class=peace type=button onClick=cls() value=Clear>";
lsHTML += "<span id=SelectDate></span> ";
lsHTML += "<input class=peace type=button onClick=Date_Up() value=\"<<\"> <input class=peace type=button onClick=Date_Down() value=\">>\"></td></tr>"
lsHTML += "</table>";
OutDate.innerHTML = lsHTML;
OutSelect();
}
function OutSelect(){
var liOutYear = miOutYear - 10;
var lsHTML = "<SELECT onPropertyChange=SelectYear(this.value)>";
for (var i=0; i<20; i++)
{
lsHTML += "<OPTION value=" + (liOutYear+i);
if (miOutYear==(liOutYear+i)) lsHTML += " SELECTED ";
lsHTML += " >" + (liOutYear+i) + "</OPTION>";
}
lsHTML += "</SELECT><SELECT onPropertyChange=SelectMonth(this.value)>";
for (var i=1; i<=12; i++){
lsHTML += "<OPTION value=" + i;
if (miOutMonth==i) lsHTML += " SELECTED ";
lsHTML += " >" + i + "</OPTION>";
}
lsHTML += "</SELECT>";
SelectDate.innerHTML = lsHTML;
}
function SelectYear(aiYear){
miOutYear = parseFloat(aiYear);
Date_Show()
}
function SelectMonth(aiMonth){
miOutMonth = parseFloat(aiMonth);
Date_Show()
}
function SelectEnd(aiDay){
dialogArguments.value = miOutYear + "-" + miOutMonth + "-" + aiDay;
window.close();
}
function Date_Down(){
miOutMonth = miOutMonth+1;
if (miOutMonth>12){
miOutMonth = 1;
miOutYear = miOutYear+1;
}
Date_Show()
}
function Date_Up(){
miOutMonth = miOutMonth-1;
if (miOutMonth<1){
miOutMonth = 12;
miOutYear = miOutYear-1;
}
Date_Show()
}
function Date_True(asDate){ //判断一个日期是否正确
var liYear = parseFloat(asDate.substring(0,asDate.indexOf("-")));
var lsTemp = asDate.substring(asDate.indexOf("-")+1);
var liMonth = parseFloat(lsTemp.substring(0,lsTemp.indexOf("-")));
var liDay = parseFloat(lsTemp.substring(lsTemp.indexOf("-")+1));
if ((!liYear)||(liYear<1900)||(liYear>2100)) return false;
if ((!liMonth)||(liMonth<1)||(liMonth>12)) return false;
var liMonthDays = getMonthDays(liYear,liMonth);
if ((!liDay)||(liDay<1)||(liDay>liMonthDays)) return false;
return true;
}
function getMonthDays(aiYear,aiMonth){ //--返回某年某月的天数
var loDay = [0,31,28,31,30,31,30,31,31,30,31,30,31];
if (aiYear%4==0) loDay[2] = 29;
return loDay[aiMonth];
}
function cls(){
dialogArguments.value = "";
window.close();
}
</SCRIPT>
</body>
</html>