导读:使用ASP做个日历很简单,下面直接给出代码,复制后拷贝到一个单独的记事本中,另存为.asp文件,配置好相应的环境就可以了,虽然简单但挺实用啊。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>简单的日历</title><style type="text/css">body{font-size:12px;}table{text-align:center;}#curr{background-color:#CC99CC;}</style></head>
<body><%dim lines,currY,currD,firDate,firWeek,maxDay,dayssub cal(dateStr)if dateStr="" thendateStr=date()end ifcurrY=year(dateStr)currM=month(dateStr)currD=day(dateStr)firDate=currY&"-"&currM&"-1"firWeek=weekDay(firDate)maxDay=day(dateSerial(y,m+1,0))days=maxDay+firWeek-1if days mod 7 = 0 thenlines=int(days/7)-1elselines=fix(days/7)end ifend sub'这样就生成2008年8月的日历'ds="2008-8-8"'call cal(ds)call cal("")%><table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25" height="25">日</td> <td width="25" height="25">一</td> <td width="25" height="25">二</td> <td width="25" height="25">三</td> <td width="25" height="25">四</td> <td width="25" height="25">五</td> <td width="25" height="25">六</td> </tr> <%for i=0 to lines%> <tr> <%for j=1 to 7square=7*i+j-firWeek+1if square<1 or square>maxDay thenresponse.Write("<td width='25' height='25'> </td>")elseif square=currD thenresponse.Write("<td width='25' height='25' id='curr'>"&square&"</td>")elseresponse.Write("<td width='25' height='25'>"&square&"</td>")end ifnext%> </tr> <%next%></table></body></html>
演示效果如下所示: