<!-- This code can be reused as long as this copyright notice is not removed --> <!-- Copyright 1999 InsideDHTML.com, LLC. All rights reserved. See www.siteexperts.com for more information. --> <STYLE TYPE="text/css"> .today {color:navy; font-weight:bold} .days {font-weight:bold} </STYLE> <SCRIPT LANGUAGE="JavaScript"> // Initialize arrays. var months = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"); var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var days = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
function getDays(month, year) { // Test for leap year when February is selected. if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28; else return daysInMonth[month]; }
var datePat = /^(\d{2}|\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; var matchArray = window.dialogArguments.match(datePat); this.year = matchArray[1]; this.month = matchArray[3]-1; this.day = matchArray[5]; }
} // Start with a calendar for today. today = new getToday(); function newCalendar() { today = new getToday(); var parseYear = parseInt(document.all.year [document.all.year.selectedIndex].text); var newCal = new Date(parseYear, document.all.month.selectedIndex, 1); var day = 0; var startDay = newCal.getDay(); var daily = 0; if ((today.year == newCal.getFullYear()) && (today.month == newCal.getMonth())) day = today.day; // Cache the calendar table's tBody section, dayList. var tableCal = document.all.calendar.tBodies.dayList; var intDaysInMonth = getDays(newCal.getMonth(), newCal.getFullYear()); for (var intWeek = 0; intWeek < tableCal.rows.length; intWeek++) for (var intDay = 0; intDay < tableCal.rows[intWeek].cells.length; intDay++) { var cell = tableCal.rows[intWeek].cells[intDay]; // Start counting days. if ((intDay == startDay) && (0 == daily)) daily = 1; // Highlight the current day. cell.className = (day == daily) ? "today" : ""; // Output the day number into the cell. if ((daily > 0) && (daily <= intDaysInMonth)) cell.innerText = daily++; else cell.innerText = ""; } } function getDate() { var sDate; // This code executes when the user clicks on a day // in the calendar. if ("TD" == event.srcElement.tagName) // Test whether day is valid. if ("" != event.srcElement.innerText) //alert(event.srcElement.innerText); sDate = document.all.year.value+"-" +document.all.month.value + "-" + event.srcElement.innerText; document.all.ret.value = sDate; window.close(); } </SCRIPT> </HEAD> <title>选择日期</title> <BODY ONLOAD="newCalendar()" OnUnload="window.returnValue = document.all.ret.value;" bgcolor="#FDFBDB" topmargin="1" leftmargin="0"> <input type="hidden" name="ret">
<HTML>
<HEAD>
<!-- This code can be reused as long as this copyright notice is not removed -->
<!-- Copyright 1999 InsideDHTML.com, LLC. All rights reserved.
See www.siteexperts.com for more information.
-->
<STYLE TYPE="text/css">
.today {color:navy; font-weight:bold}
.days {font-weight:bold}
</STYLE>
<SCRIPT LANGUAGE="JavaScript"> // Initialize arrays.
var months = new Array("一月", "二月", "三月",
"四月", "五月", "六月", "七月", "八月", "九月",
"十月", "十一月", "十二月");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31);
var days = new Array("星期日", "星期一", "星期二",
"星期三", "星期四", "星期五", "星期六");
function getDays(month, year) {
// Test for leap year when February is selected.
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}
function getToday() {
if(window.dialogArguments==""){
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
else{
var datePat = /^(\d{2}|\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/;
var matchArray = window.dialogArguments.match(datePat);
this.year = matchArray[1];
this.month = matchArray[3]-1;
this.day = matchArray[5];
}
} // Start with a calendar for today.
today = new getToday();
function newCalendar() {
today = new getToday();
var parseYear = parseInt(document.all.year
[document.all.year.selectedIndex].text);
var newCal = new Date(parseYear,
document.all.month.selectedIndex, 1);
var day = 0;
var startDay = newCal.getDay();
var daily = 0;
if ((today.year == newCal.getFullYear()) &&
(today.month == newCal.getMonth()))
day = today.day;
// Cache the calendar table's tBody section, dayList.
var tableCal = document.all.calendar.tBodies.dayList;
var intDaysInMonth =
getDays(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 0; intWeek < tableCal.rows.length;
intWeek++)
for (var intDay = 0;
intDay < tableCal.rows[intWeek].cells.length;
intDay++) {
var cell = tableCal.rows[intWeek].cells[intDay]; // Start counting days.
if ((intDay == startDay) && (0 == daily))
daily = 1; // Highlight the current day.
cell.className = (day == daily) ? "today" : ""; // Output the day number into the cell.
if ((daily > 0) && (daily <= intDaysInMonth))
cell.innerText = daily++;
else
cell.innerText = "";
}
} function getDate() {
var sDate;
// This code executes when the user clicks on a day
// in the calendar.
if ("TD" == event.srcElement.tagName)
// Test whether day is valid.
if ("" != event.srcElement.innerText)
//alert(event.srcElement.innerText);
sDate = document.all.year.value+"-" +document.all.month.value + "-" + event.srcElement.innerText;
document.all.ret.value = sDate;
window.close();
}
</SCRIPT>
</HEAD>
<title>选择日期</title>
<BODY ONLOAD="newCalendar()" OnUnload="window.returnValue = document.all.ret.value;" bgcolor="#FDFBDB" topmargin="1" leftmargin="0">
<input type="hidden" name="ret">
<TABLE ID="calendar" align="center" width="95%" border="1" cellpadding="1" cellspacing="0" height="20">
<THEAD>
<TR style="font-size:12px ">
<TD COLSPAN=7 ALIGN=CENTER style="background-color: #00FF00 border-bottom: 1 #99CCFF" height="18" valign="bottom">
<!-- Month combo box -->
<SELECT ID="month" ONCHANGE="newCalendar()">
<SCRIPT LANGUAGE="JavaScript">
// Output months into the document.
// Select current month.
for (var intLoop = 0; intLoop<months.length;
intLoop++)
document.write("<OPTION VALUE= " + (intLoop+1) + " " +
(today.month == intLoop ?
"Selected" : "") + ">" +
months[intLoop]);
</SCRIPT>
</SELECT> <!-- Year combo box -->
<SELECT ID="year" ONCHANGE="newCalendar()">
<SCRIPT LANGUAGE="JavaScript">
// Output years into the document.
// Select current year.
for (var intLoop = (new Date()).getFullYear()-50; intLoop<(new Date()).getFullYear()+100;
intLoop++)
document.write("<OPTION VALUE= " + intLoop + " " +
(today.year == intLoop ?
"Selected" : "") + ">" +
intLoop);
</SCRIPT>
</SELECT>
</TD>
</TR>
<TR CLASS="days" height="10" style="border-color:#9966FF " style="font-size:12px " >
<!-- Generate column for each day. -->
<SCRIPT LANGUAGE="JavaScript">
// Output days.
for (var intLoop = 0; intLoop < days.length;
intLoop++)
document.write("<TD>" + days[intLoop] + "</TD>");
</SCRIPT>
</TR>
</THEAD>
<TBODY ID="dayList"ALIGN=CENTER ONCLICK="getDate()">
<!-- Generate grid for individual days. -->
<SCRIPT LANGUAGE="JavaScript">
for (var intWeeks = 0; intWeeks < 6; intWeeks++) {
document.write("<TR>");
for (var intDays = 0; intDays < days.length;
intDays++)
document.write("<TD></TD>");
document.write("</TR>");
}
</SCRIPT>
</TBODY>
</TABLE>
<br>
<center><Input Style="width:30pt" type=button value="关闭" OnClick="Cancel();"></center>
</BODY>
</HTML><Script Language="JavaScript1.2"> function Cancel() {
if(window.dialogArguments==""){
document.all.ret.value = "";
}else{
document.all.ret.value = window.dialogArguments;
}
window.close();
}</script>