日期:2014-05-16  浏览次数:20375 次

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_sel