asp日期函数运用--生成简单的日历

作者:亮亮 来源:亮亮blog 时间:2008-08-15 13:47:00 

下面的代码是日期函数的一些简单运用,应该不用解释,生成当月的日历,当然你可以根据实际情况进行扩充!

效果图:

<%@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=utf-8" />
<title>asp日历代码</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,days
sub cal(dateStr)
if dateStr="" then
dateStr=date()
end if
currY=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-1
if days mod 7 = 0 then
lines=int(days/7)-1
else
lines=fix(days/7)
end if
end 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 7
square=7*i+j-firWeek+1
if square<1 or square>maxDay then
response.Write("<td width='25' height='25'> </td>")
elseif square=currD then
response.Write("<td width='25' height='25' id='curr'>"&square&"</td>")
else
response.Write("<td width='25' height='25'>"&square&"</td>")
end if
next
%>
  </tr>
  <%next%>
</table>
</body>
</html>
标签:日历,函数,日期,asp
0
投稿

猜你喜欢

  • 优雅地扩大链接响应区域

    2010-09-25 13:04:00
  • FireScope-面向Web开发者和设计者的参考手册

    2009-03-22 15:35:00
  • 在系统崩溃的时候如何恢复原有的数据

    2009-01-08 13:26:00
  • asp精妙的SQL语句例子

    2008-03-04 17:42:00
  • 使用NetBox 编译 asp 为exe应用程序

    2009-11-29 16:13:00
  • 15款非常有用的前端开发CSS网格(grid system)生成器

    2009-07-06 13:02:00
  • 给页面 unload 加上效果

    2009-03-12 12:32:00
  • Oracle学习笔记(五)

    2012-01-05 18:52:30
  • 新浪微博文字渐隐效果

    2011-04-29 12:33:00
  • 实用技巧:优化SQL Server数据库查询方法

    2009-02-04 13:46:00
  • 用户体验中的五大要素

    2008-07-07 16:41:00
  • asp读取xml实例代码

    2011-03-08 11:13:00
  • sql数据库批量处理脚本

    2011-11-03 17:23:19
  • [翻译]标记语言和样式手册 Chapter 2 标题

    2008-01-16 11:56:00
  • 教程:MySQL中多表操作和批处理方法

    2009-07-30 08:20:00
  • 以图换字的几个方法及思路

    2007-10-17 18:07:00
  • 细化解析:MySQL 数据库中对XA事务的限制

    2009-01-14 11:59:00
  • 页面表达常用方式

    2010-05-27 12:42:00
  • ASP.NET教程第二讲 ASP.NET学习

    2007-08-07 12:01:00
  • 当视觉设计师遇上产品经理、开发工程师…[译]

    2010-01-17 10:18:00
  • asp之家 网络编程 m.aspxhome.com