写个简单ASP日历

<!--电子表-->

<div id="center_left_3"><strong>时间:</strong><input id="thetime" size="8" style="border:0;">
    <script type="text/javascript">
 var timerID = null;
    var timerRunning = false;
    function stopclock() {
        if (timerRunning)
            clearTimeout(timerID);
        timerRunning = false;
    }
    function startclock() {
        stopclock();
        showtime();
    }
    function showtime() {
     var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds();
     var timeValue = "" + ((hours <= 12) ? " " : " ");
        timeValue += (hours);
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
  document.getElementById("thetime").value = timeValue;
  timerID = setTimeout(showtime, 1000);
        timerRunning = true;
    }
 startclock();
</script>
<br />

<!--电子表结束-->
         <strong>日期:</strong><%=Year(now())%>年:<%=Month(now())%>月<%=day(now())%>日</div>
    <div id="center_left_4">

<!--日历正式开始-->
      <div id="center_left_4_1">日历</div>
   <div id="center_left_4_2" class="d1">&nbsp;<a href="#">〈</a>&nbsp;<%=Year(now())%>/<%=Month(now())%>&nbsp;&nbsp;<a href="#">〉</a></div>
    </div>
    <div id="center_left_5">
      <ul class="css_2">
<%
Dim dDate     ' 日历显示的日期
Dim iDOW      ' 每一月开始的日期
Dim iCurrent  ' 当前日期
Dim iPosition ' 表格中的当前位置

dDate = Date()
'得到日期后我们先得到这个月的天数及这个月的起始日期.
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)
%>

     <li>S</li>
     <li>M</li>
     <li>T</li>
     <li>W</li>
     <li>T</li>
     <li>F</li>
     <li>S</li>
 <%
 ' 如果这个月的起始日期不是周日的话就加空的单元
If iDOW <> 1 Then
 iPosition = 1
 Do While iPosition < iDOW
  Response.Write "<li>"& vbCrLf &"</li>"
  iPosition = iPosition + 1
 Loop
End If

' 绘制这个月的日历
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
' 如果这一天是我们选择的日期就高亮度显示该日期.
 If iCurrent = Day(dDate) Then
  Response.Write  "<li style='color:orange;'>" & iCurrent & "</li>"
 Else
  Response.Write "<li>" & iCurrent & "</li>"
 End If
 iCurrent = iCurrent + 1
 iPosition = iPosition + 1
Loop


%>

   </ul>
    </div>

相关CSS就不贴了,效果如图:

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值