欢迎光临
我们一直在努力

功能非常全面的日期处理函数

建站超值云服务器,限时71元/月

<script language=javascript>
function fnsubmit(strpage)
{
  document.forms[0].action= strpage
  document.forms[0].submit()    
}

</script>
<%

call writedropdowns

sub writedropdowns()
  dim strselflink
  strselflink = request.servervariables("script_name")
  response.write "<form name=dates method=post>" & vbcrlf
  response.write monthdropdown("month1",false,request("month1"),strselflink) & " " & daydropdown("day1", "",getdaysinmonth(request("month1"),request("year1")),request("day1")) & " " & yeardropdown("year1","","", request("year1"),strselflink) & vbcrlf
  response.write "</form>"    & vbcrlf
end sub
        

function monthdropdown(strname, blnnum, strselected, strselflink)
  dim strtemp, i, strselectedstring            
  strtemp = "<select name=" & strname& " onchange=javascript: fnsubmit(" & chr(34) & strselflink & chr(34) & ")>" & vbcrlf
  strtemp = strtemp & "<option value=" & 0 & ">" & "month" & "</option>" & vbcrlf            
  for i = 1 to 12
    if strselected = cstr(i) then
    strselectedstring = "selected"
    else
    strselectedstring = ""
    end if
            
    if blnnum then
      strtemp = strtemp & "<option value=" & i & " " & strselectedstring & " >" & i & "</option>" & vbcrlf            
    else
    strtemp = strtemp & "<option value=" & i & " " & strselectedstring & " >" & monthname(i) & "</option>" & vbcrlf            
    end if
  next                    
  strtemp = strtemp & "</select>" & vbcrlf    
  monthdropdown = strtemp
end function

function yeardropdown(strname, intstartyear, intendyear, strselected, strselflink)
  
  dim strtemp, i, strselectedstring    
  
  if intstartyear = "" then
    intstartyear = year(now())
  end if    
    
  if intendyear = "" then
    intendyear = year(now()) + 9
  end if
    
  strtemp = "<select name=" & strname& " onchange=javascript: fnsubmit(" & chr(34) & strselflink & chr(34) & ")>" & vbcrlf            
  strtemp = strtemp & "<option value=" & 0 & ">" & "year" & "</option>" & vbcrlf            
  for i = intstartyear to intendyear        
    if strselected = cstr(i) then
      strselectedstring = "selected"
    else
      strselectedstring = ""
    end if
    strtemp = strtemp & "<option value=" & i & " " & strselectedstring & " >" & i & "</option>" & vbcrlf                            
   next                    
   strtemp = strtemp & "</select>" & vbcrlf    
   yeardropdown = strtemp
end function

function daydropdown(strname, intstartday, intendday, strselected )
    dim strtemp, i, strselectedstring    
    if intstartday = "" then
      intstartday = 1
    end if    
    
    if intendday = "" then
      intendday = getdaysinmonth(month(now()),year(now()))
    end if
    
    strtemp = "<select name=" & strname& ">" & vbcrlf            
    strtemp = strtemp & "<option value=" & 0 & ">" & "day" & "</option>" & vbcrlf            
    for i = intstartday to intendday
      if strselected = cstr(i) then
        strselectedstring = "selected"
      else
        strselectedstring = ""
      end if
      strtemp = strtemp & "<option value=" & i & " " & strselectedstring & " >" & i & "</option>" & vbcrlf                            
    next                    
    strtemp = strtemp & "</select>" & vbcrlf    
    daydropdown = strtemp
end function

function getdaysinmonth(strmonth,stryear)
        dim strdays     
    select case cint(strmonth)
        case 1,3,5,7,8,10,12:
        strdays = 31
        case 4,6,9,11:
           strdays = 30
        case 2:
        if  ( (cint(stryear) mod 4 = 0  and  cint(stryear) mod 100 <> 0)  or ( cint(stryear) mod 400 = 0) ) then
          strdays = 29
        else
          strdays = 28
        end if    
        case else:
    end select
        
    getdaysinmonth = strdays
end function    
%>    

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 功能非常全面的日期处理函数
分享到: 更多 (0)