过程名:echo
'作 用:输出html
'参 数:str ----输出的内容
'///////////////////////////////////////////////////
Sub echo(str)
response.write(str)
response.Flush()
End Sub
'=======================================================
'获得当月天数
Function GetDays(tDate)
dt1 = CDate(Year(tDate) & "-" & Month(tDate) & "-1") ' 得到本月第一天
dt2 = DateAdd("m",1,dt1) ' 得到下个月第一天
GetDays=DateDiff("d",dt1,dt2) ' 得到两个月的差
End Function
'=======================================================
sub makeCalendar()
dateStr=date()'或得当前日期
currY=year(dateStr)'获得当前年
currM=month(dateStr)'获得当前月
currD=day(dateStr)'获得当前日
firDate=currY&"-"&currM&"-1"'或得当月第一天
firWeek=weekDay(firDate,vbMonday)'或得当月第一天是星期几
maxDay=GetDays(dateStr)'获得当月的最大天数
days=maxDay+firWeek-1'获得表格的天数
if days mod 7 = 0 then
lines=int(days/7)-1
else
lines=fix(days/7)
end if
echo"<table border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"" width=""600"" bgcolor=""#FFFFFF"">"&vbcrlf
echo" <caption>"&currM&"月份日历</caption>"
echo" <tr>"&vbcrlf
echo" <th width=""14%"" height=""40"">日</th>"&vbcrlf
echo" <th width=""14%"">一</th>"&vbcrlf
echo" <th width=""14%"">二</th>"&vbcrlf
echo" <th width=""14%"">三</th>"&vbcrlf
echo" <th width=""14%"">四</th>"&vbcrlf
echo" <th width=""14%"">五</th>"&vbcrlf
echo" <th width=""14%"">六</th>"&vbcrlf
echo" </tr>"&vbcrlf
for i=0 to lines
echo" <tr>"&vbcrlf
for j=1 to 7
square=7*i+j-firWeek
if square<1 or square>maxDay then
echo"<td height=""40""> </td>"&vbcrlf
elseif square=currD then
echo"<td id='curr'>"&square&"</td>"&vbcrlf
else
echo"<td height=""40"">"&square&"</td>"&vbcrlf
end if
next
echo" </tr>"&vbcrlf
next
echo"</table>"&vbcrlf
end sub
call makeCalendar()'生成日历
CSS部分:
caption{font-size:16px; font-weight:bold; padding:10px;}
th,td{padding:5px;}
th{border:1px solid #5C47C2;}
td{text-align:center; border:1px solid #CCC;}
#curr{background-color:#EEE;}