写个简单ASP日历

    技术2022-05-19  19

    <!--电子表-->

    <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"> <a href="#">〈</a> <%=Year(now())%>/<%=Month(now())%>  <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 LoopEnd If

    ' 绘制这个月的日历iCurrent = 1iPosition = iDOWDo 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 + 1Loop

    %>

       </ul>    </div>

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

     

     


    最新回复(0)