转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 站长学院 >> Web开发 >> 正文
多种Web脚本语言下的日历实现         ★★★★

多种Web脚本语言下的日历实现

作者:闵涛 文章来源:闵涛的学习笔记 点击数:4190 更新时间:2009/4/23 10:33:30
bsp;      if i>nunmonthstart and i<=nunmonthend+nunmonthstart then
60            '如果为显示的是今天则用红色背景显示
61            if iv=Day(now) and month(now)=pmonth and year(now)=pyear then
62                response.write( "<td align=center bgcolor=ffaaaa><a href='#' target=_blank>" & iv & "</a></td>")
63            else
64                response.write( "<td align=center><a href='#' target=_blank>" & iv & "</a></td>")
65            end if
66        else
67            response.write( "<td> </td>")
68        end if
69
70        '如果能被7整除(每行显示7个)则输出一个换行
71        if i mod 7=0 then
72            response.write( "</tr><tr align=center bgcolor=ffffff height=19>")
73        end if
74        i=i+1
75    loop
76%>
77</table>
78</body>

具体实现效果如下:

 

 

下面是根据上述算法和逻辑在PHP中的具体实现代码:

 1<style>
 2td { font-family: "宋体"; font-size:9pt}
 3</style>
 4<body bgcolor="eeeeee">
 5<table width="180" cellpadding="0" cellspacing="1" bgcolor="dddddd" align=center>
 6<?
 7//以下为PHP中通过该日历算法实现的具体代码
 8
 9    //先判断是否指定了一个年份和月份,没有则根据当前的年和月份显示
10    if($ReqDate==""){
11        $pyear=date("Y");
12        $pmonth=date("m");
13        $CurrentDate=date("Y-m-j");
14    }else{
15        $ReqDateStrs = explode("-",$ReqDate );
16        $pyear=$ReqDateStrs[0];
17        $pmonth=$ReqDateStrs[1];
18        $CurrentDate=$ReqDate;
19    }
20
21//以下的代码生成日历显示的表格头内容
22?>
23<tr align="center" bgcolor="#dddddd"> 
24    <td width="14%" height="19" align="center">
25        <input type="button" value="<<" onclick="JavaScript:location.href='?ReqDate=<? echo date("Y-m-j",mktime(0,0,0,$pmonth-1,1,$pyear)); ?>'">
26    </td>
27    <td colspan="5" align="center">
28        <? echo $CurrentDate; ?>
29    </td>
30    <td width="14%" align="center">
31        <input type="button" value=">>" onclick="JavaScript:location.href='?ReqDate=<? echo date("Y-m-j",mktime(0,0,0,$pmonth+1,1,$pyear)); ?>'">
32    </td>
33  </tr>
34  <tr align="center" bgcolor="#CCCCCC"> 
35    <td width="14%" height="19"> 日</td>
36    <td width="14%"> 一</td>
37    <td width="14%"> 二</td>
38    <td width="14%"> 三</td>
39    <td width="14%"> 四</td>
40    <td width="14%"> 五</td>
41    <td width="14%"> 六</td>
42  </tr>
43  <tr align=center bgcolor=ffffff height=19>
44<?
45    //获得要显示月份的第一天为周几
46    $nunmonthstart=date('w',mktime(0,0,0,$pmonth,1,$pyear));
47    //获得要显示月份一共有多少天
48    $nunmonthend=date('t',mktime(0,0,0,$pmonth,1,$pyear));
49    //判断显示日历需要用几行表格来显示(每行显示7天)
50    if($nunmonthstart+$nunmonthend<36){
51        $maxi=36;
52    }
53    else{
54        $maxi=43;
55    }
56    //循环生成表格并显示
57    for( $i=1; $i <$maxi; $i++)
58    {
59        $iv=$i-$nunmonthstart;
60        if($i>$nunmonthstart && $i<=$nunmonthend+$nunmonthstart) {
61            //如果为显示的是今天则用红色背景显示
62

上一页  [1] [2] [3] [4] [5]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Web开发  · 网页制作
    · 平面设计  · 网站运营
    · 网站推广  · 搜索优化
    · 建站心得  · 站长故事
    · 互联动态
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台