您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
功能非常全面的日期处理函数
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 13:21:47
<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    
%>    


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |