Copy Code code as follows:
<style>
TD {Font-family: "Song Body"; 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
' First decide whether to specify a year and month, no to display according to the current year and month
If Request ("reqdate") = "" Then
Currentdate=date
Else
Currentdate=trim (Request ("Reqdate"))
End If
Pyear=year (currentdate)
Pmonth=month (currentdate)
' The following code generates the table header contents displayed in the Calendar
%>
<tr align= "left" bgcolor= "#dddddd" >
<TD width= "14%" height= "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= "> Day </td>
<TD width= "14%" > </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>
<%
' Because the ASP does not get the number of days in a specified month, so we need to get through other algorithms, the algorithm is actually very simple, that is, to show the month of 1st to the next month of 1st a total difference of several days
FromDate = FormatDateTime (Month (currentdate) & "/1/" & Year (currentdate))
ToDate = FormatDateTime (DateAdd ("M", 1,fromdate))
' Get the first day of the month to display the week
Nunmonthstart=weekday (fromdate)-1
' Get to show 1st to the next month of 1st a total difference of several days (how many days in the month)
Nunmonthend=datediff ("D", Fromdate,todate)
' The decision to display the calendar needs to be displayed in several rows of tables (7 days per line)
If Nunmonthstart+nunmonthend<36 Then
maxi=36
Else
maxi=43
End If
' Loop to generate the table and display
I=1
Do While I<maxi
Iv=i-nunmonthstart
If I>nunmonthstart and I<=nunmonthend+nunmonthstart then
' If the display is today, it will be displayed with a red background.
If Iv=day (now) =pmonth and Month (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
' If it can be divisible by 7 (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+1
Loop
%>
</table>
</body>