Asp学习站欢迎你!

一个关于日期选择的很实用的小东西

来源:ASP学习网 作者:Admin 时间:08-06-21 点击:

以前做页面时经常需要制作日期选择框,例如出生日期、查询日期等等,通常的做法是制作三个下拉列表(select),分别用于选择年、月、日,但该方法在各方面的表现都很令人不耐烦,于是我做了这个日期选择页面,它不是组件,也不是函数,只是一个普通的ASP页面,用于返回用户选择的日期变量。

************************************************************************

<%
'day.asp
%>
<html>
 <head>
  <title>选择日期                </title>
   <style type=text/css>
    <!--
    body{margin:0;font-size:9pt;color:#5E639B}
    td{font-size:9pt;color:#000000}
    a:link {color:#000000;text-decoration: none}
    a:visited {color:#000000;text-decoration: none}
    a:active {color:#000000;text-decoration: none}
    a:hover { color:#ff3333;text-decoration: none}
    -->
   </style>
   <Script  Language="JavaScript">
    function getDay(v){
     window.opener.document.<%=request.querystring("form")%>.<%=request.querystring("field")%>.value=v;
     window.close();
     return false;
    }
   </Script>
 </head>
 <body bgcolor=#ffffff onBlur="window.focus()">
<%
oldDate=request("oldDate")
if not isDate(oldDate) then oldDate=date
yy=year(cdate(oldDate))
mm=month(cdate(oldDate))
if request("yy")<>"" then yy=request("yy")
if request("mm")<>"" then mm=request("mm")
if yy="" then yy=year(date)
if mm="" then mm=month(date)
if mm>12 then mm=1:yy=yy+1
if mm<1 then mm=12:yy=yy-1

dim m(12)
m(1)=31
m(3)=31
m(5)=31
m(7)=31
m(8)=31
m(10)=31
m(12)=31
m(2)=28
m(4)=30
m(6)=30
m(9)=30
m(11)=30
if (yy mod 4=0 and yy mod 100<>0) or yy mod 400=0 then m(2)=29
mms=m(mm)
week1=(weekday(cdate(yy & "-" & mm & "-1"))-1)
%>
     <table width=250 cellspacing=1 cellpadding=0 bgcolor=#FFDFDF align=center>
      <tr>
       <td colspan=7 align=center>
        <table width=100% height=20 cellspacing=0 cellpadding=0>
         <tr height=20>
          <td width=30 align=center>
           <a href=day.asp?form=<%=request("form")%>&field=<%=request("field")%>&yy=<%=(yy-1)%>&mm=<%=mm%>>
            <font face=webdings style=color:#000000 title="上一年">7</font>
           </a>
          <td width=30 align=center>
           <a href=day.asp?form=<%=request("form")%>&field=<%=request("field")%>&mm=<%=(mm-1)%>&yy=<%=yy%>>
            <font face=webdings style=color:#000000 title="上一月">3</font>
           </a>
          <td width=130 align=center style="FONT:9pt Verdana,Geneva,sans-serif;color:#CD0101">
           <b><%=yy%> 年 &nbsp; <%=mm%> 月</b>
          <td width=30 align=center>
           <a href=day.asp?form=<%=request("form")%>&field=<%=request("field")%>&mm=<%=(mm+1)%>&yy=<%=yy%>>
            <font face=webdings style=color:#000000 title="下一月">4</font>
           </a>
          <td width=30 align=center>
           <a href=day.asp?form=<%=request("form")%>&field=<%=request("field")%>&yy=<%=(yy+1)%>&mm=<%=mm%>>
            <font face=webdings style=color:#000000 title="下一年">8</font>
      &

打印】 【关闭
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 验证码: 验证码 查看所有评论