<p><style>td { font-family: "安体"; font-size:9pt}</style><body bgcolor="eeeeeeee"><table cellpadding="0" cellpacing="1" bgcolor="ddddddd" align=center><%'The following are the specific codes implemented in ASP through this calendar algorithm</p><p>'First determine whether a year and month are specified, and if no, it will be displayed based on the current year and month. If Request("ReqDate")="" then CurrentDate=Date else CurrentDate=Trim(Request("ReqDate")) end if pyear=year(CurrentDate) pmonth=month(CurrentDate)</p><p>'The following code generates the table header content for the calendar display %> <tr align="LEFT" bgcolor="#ddddddd"> <td 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 align="center"> <input type="button" value=">>" onclick="JavaScript:location.href='?ReqDate=<%=DateAdd("m",1,CurrentDate)%>'"></td> </tr> <tr align="center" bgcolor="#CCCCCC"> <td>Day</td> <td>one</td> <td>two</td> <td>three</td> <td>four</td> <td>five</td> <td>six</td> </tr> <tr align=center bgcolor=ffffff height=19> <% 'Since there is no function in ASP that specifies how many days there are in total for the specified month, we need to obtain it through other algorithms. The algorithm is actually very simple, which is to calculate how many days there is in total between the 1st day of the month to be displayed fromDate = FormatDateTime(month(CurrentDate) & "/1/" & year(CurrentDate)) toDate = FormatDateTime(DateAdd("m",1,fromDate)) 'Get the week of the month to be displayed nunmonthstart=weekday(fromDate)-1 'Get the total between the 1st day of the month to be displayed from the 1st day to the 1st day of the next month to be displayed (how many days there are in total) nunmonthend=DateDiff("d",fromDate, toDate) 'To determine how many rows of tables are needed to display the calendar (7 days per row) if nunmonthstart+nunmonthend<36 then maxi=36 else maxi=43 end if 'Change to generate the table and display i=1 do while i<maxi iv=i-nunmonthstart if i>nunmonthstart and i<=nunmonthend+nunmonthstart then 'If iv=Day(now) and month(now)=pmonth and year(now)=pyear then response.write( "<td align=center bgcolor=ffaaa>" & iv & "</td>") else response.write( "<td align=center>" & iv & "</td>") end if else response.write( "<td></td>") end if</p><p> 'If it can be divisible by 7 (7 are displayed 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> [Ctrl+A Select all Note: If you need to introduce external Js, you need to refresh to execute]