jsp 日历的源码
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<html>
<head>
<title>日期选择器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body,td { font-size:9pt; }
input
{
color:333333;
font-size:9pt;
border-width:0;
padding:2;
width:20;
}
</style>
</head>
<script language=javascript>
<!--
var monthNames = new Array ( "", "1","2","3","4","5","6","7", "8", "9", "10", "11", "12" );
var endDay = new Array ( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
var dayNow = 0;
var monthNow = 0;
var yearNow = 0;
function load ( form ) {
set_month_year_now ();
var found = false;
for ( var month=0; month<form.monthList.length; month++ )
if ( form.monthList[month].text == monthNames[monthNow] ) {
form.monthList[month].selected = true;
found = true;
}
if ( !found) {
error ();
return;
}
var found = false;
for ( var year=0; year<form.yearList.length; year++ )
if ( form.yearList[year].text == yearNow ) {
form.yearList[year].selected = true;
found = true;
}
if ( !found) {
error ();
return;
}
display_month ( form );
}
function preceding_month ( form ) {
var month_selected = form.monthList.selectedIndex;
var year_selected = form.yearList.selectedIndex;
if ( !month_selected && !year_selected ) {
error ();
return;
}
if ( month_selected > 0 )
month_selected --;
else {
month_selected = 11;
year_selected --;
}
form.monthList[month_selected].selected = true;
form.yearList[year_selected].selected = true;
display_month ( form );
}
function following_month ( form ) {
var month_selected = form.monthList.selectedIndex;
var year_selected = form.yearList.selectedIndex;
if ( month_selected >= ( form.monthList.length - 1 ) && year_selected >= ( form.yearList.length - 1 ) ) {
error ();
return;
}
if ( month_selected < 11 )
month_selected ++;
else {
month_selected = 0;
year_selected ++;
}
form.monthList[month_selected].selected = true;
form.yearList[year_selected].selected = true;
display_month ( form );
}
function set_month_year_now () {
var form = document.calendar;
var now = new Date ();
monthNow = now.getMonth () + 1;
yearNow = now.getYear ();
dayNow = now.getDate();
yearNow = ( yearNow < 100 ) ? yearNow + 1900 : yearNow;
var count = 0
for (var i = yearNow-103; i < yearNow + 50; i++) {
eval("form.yearList.options[count] = new Option('"+i+"', '"+i+"')");
count++;
}
form.yearList.selectedIndex = 103;
form.yearList.length = count;
}
function error () {
alert ( "超出范围!" );
}
function display_month ( form ) {
var month = form.monthList.selectedIndex + 1;
var year = parseInt ( form.yearList.options[ form.yearList.selectedIndex].text );
var start_day = start_day_in_month ( year, month );
补充:Web开发 , Jsp ,