Copy codeThe Code is as follows: <style>
Td {font-family: ""; font-size: 9pt}
</Style>
<Body bgcolor = "eeeeee">
<Table width = "180" cellpadding = "0" cellspacing = "1" bgcolor = "dddddd" align = center>
<%
'The following code is implemented using the calendar algorithm in ASP.
'Determine whether a year and month are specified first. If not, it is 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)
'The following code generates the table header content displayed in the calendar
%>
<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>
& Lt; td width = "14%" align = "center" & gt;
<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%"> 1 </td>
<Td width = "14%"> 2 </td>
<Td width = "14%"> 3 </td>
<Td width = "14%"> 4 </td>
<Td width = "14%"> 5 </td>
<Td width = "14%"> 6 </td>
</Tr>
<Tr align = center bgcolor = ffffff height = 19>
<%
'The ASP does not obtain the number of days in a specified month, so we need to use other algorithms. The algorithm is actually very simple, is to calculate the number of days from the first day of the month to the first day of the next month.
FromDate = FormatDateTime (month (CurrentDate) & "/1/" & year (CurrentDate ))
ToDate = FormatDateTime (DateAdd ("m", 1, fromDate ))
'The first day of the month to be displayed is the day of the week.
Nunmonthstart = weekday (fromDate)-1
'Obtain the total number of days from the first day of the month to the next month (the total number of days in the month)
Nunmonthend = DateDiff ("d", fromDate, toDate)
'Determine how many rows of tables are needed to display the calendar (7 days for each row)
If nunmonthstart + nunmonthend <36 then
Maxi = 36
Else
Maxi = 43
End if
'Generate and display the table cyclically
I = 1
Do while I <maxi
Iv = I-nunmonthstart
If I> nunmonthstart and I <= nunmonthend + nunmonthstart then
'If it is today, it is displayed in 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
'If 7 is divisible (7 lines are displayed), a line break is output.
If I mod 7 = 0 then
Response. write ("</tr> <tr align = center bgcolor = ffffff height = 19> ")
End if
I = I + 1
Loop
%>
</Table>
</Body>