<P><style>td { font-family: 宋体; font-size:9pt}</style><body bgcolor=eeeeee><table width=180 cellpadding=0 cellspacing=1 bgcolor=dddddd align=center><% 'The following is the specific code implemented by this calendar algorithm in ASP</P><P> 'First determine whether a year and month are specified, if not, display the If based on the current year and month Request(ReqDate)= then CurrentDate=Dateelse CurrentDate=Trim(Request(ReqDate))end ifpyear=year(CurrentDate)pmonth=month(CurrentDate)</P><P> 'The following code generates the table header content for calendar display% > <tr align=LEFT bgcolor=#dddddd> <td width=14% height=19 align=center> <input type=button value=<< onclick=JavaScript:location.href='?ReqDate=<%=DateAdd(m,-1,CurrentDate) %>'></td> <td colspan=5 align=center> <%=pyear% >Year<%=pmonth%>Month</td> <td width=14% align=center> <input type=button value=>> onclick=JavaScript:location.href='?ReqDate=<%=DateAdd(m,1,CurrentDate)%>'></td> </tr> <tr align=center bgcolor=#CCCCCC> <td width=14 % height=19> day</td> <td width=14%> one</td> <td width=14%> two</td> <td width=14%> three</td> <td width=14%> four</td> <td width=14%> five</td> <td width=14%> six</td> </tr> <tr align=center bgcolor=ffffff height=19> <% 'Since there is no function in ASP to obtain the number of days in a specified month, we need to use other algorithms to obtain it. The algorithm is actually very simple, which is to calculate the total number of days between the 1st of the month to be displayed and the 1st of the next month fromDate = FormatDateTime(month(CurrentDate) & /1/ & year(CurrentDate))toDate = FormatDateTime(DateAdd(m,1,fromDate))'Get the day of the week when the first day of the month to be displayed is nunmonthstart=weekday(fromDate)-1'Get the total number of days between the 1st day to be displayed and the 1st day of the next month ( How many days are there in the month)nunmonthend=DateDiff(d,fromDate,toDate)' Determine how many rows of tables need to be used to display the calendar (each row displays 7 days) if nunmonthstart+nunmonthend<36 then maxi=36else maxi=43end if'Loop to generate the table and display i=1do while i<maxi iv=i-nunmonthstart if i>nunmonthstart and i<=nunmonthend+nunmonthstart then 'If what is displayed is today Then display it with a red background if iv=Day(now) and month(now)=pmonth and year(now)=pyear then response.write( <td align=center bgcolor=ffaaaa><a href='#' target=_blank> & iv & </a></td>) else response.write( <td align=center><a href='#' target= _blank> & iv & </a></td>) end if else response.write( <td> </td>) end if</P><P> 'If it is divisible by 7 (display 7 per line), output a newline if i mod 7=0 then response.write( </tr><tr align=center bgcolor=ffffff height=19>) end if i=i +1loop%></table></body>