login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > ASP > Kalenders > kalender in ASP

kalender in ASP

Auteur: Thomas - 21 november 2004 - 00:42 - Gekeurd door: Dennisvb - Hits: 5857 - Aantal punten: 5.00 (7 stemmen)





Dit script drukt een kalender af met behulp van ASP.
Je kan schakelen tussen de verschillende maanden met een "previous" en "next" knop of met een selectbox voor maand en jaar.

Code:
  1. <% @LANGUAGE=VBScript %>
  2. <% Option Explicit
  3. Response.Expires = 0
  4. SetLocale("nl-nl")
  5. %>
  6. <HTML>
  7. <HEAD>
  8. <TITLE>ASP kalender</TITLE>
  9. <STYLE TYPE="text/css">
  10. <!--
  11. .today {FONT-WEIGHT: bold;
  12. BACKGROUND-COLOR: #cccccc;}
  13.  
  14. TABLE {BORDER-RIGHT: 1px solid #000000;
  15. BORDER-BOTTOM: 1px solid #000000;}
  16.  
  17. SELECT, INPUT, .def {FONT-FAMILY: Arial;
  18. FONT-SIZE: 9pt;}
  19.  
  20. TD {BORDER-LEFT: 1px solid #000000;
  21. BORDER-TOP: 1px solid #000000;
  22. FONT-FAMILY: Arial;
  23. FONT-SIZE: 9pt;}
  24.  
  25. .grey {FONT-WEIGHT: bold;
  26. BACKGROUND-COLOR: #e0e0e0;}
  27.  
  28. -->
  29. </STYLE>
  30. </HEAD>
  31.  
  32. <BODY CLASS="def">
  33. <%
  34. Dim intMaand, intJaar, intAantalWeken, strEDag, strLDag, intDagenInMaand, strToday
  35. Dim aDagNamen
  36. Dim t1, t2, tdag, tweek
  37.  
  38. Function addLeadingZero(value)
  39. 'pre: value is an integer value
  40. 'return: the value, converted to a string, with a leading zero if
  41. ' the original value is smaller than 10
  42. If value < 10 Then
  43. value = "0" & CStr(value)
  44. Else
  45. value = CStr(value)
  46. End If
  47. addLeadingZero = value
  48. End Function
  49.  
  50. aDagNamen = Array("Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo")
  51. strToday = Date()
  52.  
  53. If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
  54. If Request.Form("action") = "submit" Then
  55. 'bovenste formulier
  56. intMaand = CInt(Request.Form("month"))
  57. intJaar = CInt(Request.Form("year"))
  58. End If
  59. If Request.Form("action") = "previous" Then
  60. 'previous-knop; haal waarden op
  61. intMaand = CInt(Request.Form("m"))
  62. intJaar = CInt(Request.Form("y"))
  63. 'verlaag met 1 maand
  64. If intMaand > 1 Then
  65. intMaand = intMaand - 1
  66. Else
  67. intMaand = 12
  68. intJaar = intJaar - 1
  69. End If
  70. End If
  71.  
  72. If Request.Form("action") = "next" Then
  73. 'next-knop; haal waarden op
  74. intMaand = CInt(Request.Form("m"))
  75. intJaar = CInt(Request.Form("y"))
  76. 'verhoog met 1 maand
  77. If intMaand < 12 Then
  78. intMaand = intMaand + 1
  79. Else
  80. intMaand = 1
  81. intJaar = intJaar + 1
  82. End If
  83. End If
  84. Else
  85. 'niets ingevuld, pak datum van vandaag
  86. intMaand = DatePart("m", strToday)
  87. intJaar = DatePart("yyyy", strToday)
  88. End If
  89.  
  90. 'Bepaal eerste dag van de huidige maand
  91. strEDag = CDate("1-" & intMaand & "-" &intJaar)
  92. 'Bepaal het aantal dagen in deze maand
  93. intDagenInMaand = DateDiff("d", strEDag, DateAdd("m", 1, strEDag))
  94. 'Bepaal de laatste dag van deze maand
  95. strLDag = CDate(intDagenInMaand & "-" & intMaand & "-" & intJaar)
  96. 'Bepaal het aantal jaarweken waarin deze maand zit
  97. intAantalWeken = DatePart("ww", strLDag, vbMonday) - DatePart("ww", strEDag, vbMonday) + 1
  98.  
  99. Response.Write "Eerste dag van de maand: " & FormatDateTime(strEDag, vbLongDate) & "<BR>" & vbLf
  100. Response.Write "Laatste dag van de maand: " & FormatDateTime(strLDag, vbLongDate) & "<BR>" & vbLf
  101. %>
  102. <FORM ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>" METHOD="post">
  103. <SELECT NAME="month">
  104. <%
  105. For t1=1 To 12
  106. Response.Write "<OPTION VALUE=""" & t1 & """"
  107. If t1 = intMaand Then Response.Write " SELECTED" End If
  108. Response.Write ">" & MonthName(t1) & "</OPTION>" & VBLf
  109. Next
  110. %>
  111. </SELECT>
  112. <SELECT NAME="year">
  113. <%
  114. For t1=1995 To 2015
  115. Response.Write "<OPTION VALUE=""" & t1 & """"
  116. If t1 = intJaar Then Response.Write " SELECTED" End If
  117. Response.Write ">" & t1 & "</OPTION>" & VBLf
  118. Next
  119. %>
  120. </SELECT>
  121. <INPUT TYPE="submit" NAME="action" VALUE="submit">
  122. </FORM>
  123.  
  124. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
  125. <TR><TD COLSPAN="<%= (intAantalWeken+1) %>" ALIGN="center"><B><%= MonthName(intMaand) & " " & intJaar %></B></TD></TR>
  126. <%
  127. Response.Write "<TR>" & VBLf
  128. Response.Write "<TD>&nbsp;</TD>" 'extra veld voor dagen-kolom
  129. For t1 = 0 To intAantalWeken-1
  130. tweek = DatePart("ww", strEDag, vbMonday) + t1
  131. Response.Write "<TD CLASS=""grey"">"
  132. If tweek > 52 Then
  133. Response.Write "&nbsp;"
  134. Else
  135. Response.Write addLeadingZero(tweek)
  136. End If
  137. Response.Write "</TD>" & VBLf
  138. Response.Write "</TR>"& VBLf
  139.  
  140. For t2 = 1 to 7
  141. Response.Write "<TR>" & VBLf
  142. Response.Write "<TD CLASS=""grey"" ALIGN=""center"">" & aDagNamen(t2-1) & "</td>" & VBLf
  143. For t1 = 0 To intAantalWeken-1
  144. tdag = t1*7+t2 - WeekDay(strEDag, vbMonday) + 1
  145. Response.Write "<TD"
  146. If tdag >=1 And tdag <= intDagenInMaand Then
  147. If DateValue(tdag & "-" & intMaand & "-" & intJaar) = strToday Then
  148. Response.Write " CLASS=""today"""
  149. End If
  150. End If
  151. Response.Write ">"
  152. If tdag < 1 Or tdag > intDagenInMaand Then
  153. Response.Write "&nbsp;"
  154. Else
  155. Response.Write addLeadingZero(tdag)
  156. End If
  157. Response.Write "</TD>" & VBLf
  158. Next 't1
  159. Response.Write "</TR>" & VBLf
  160. Next 't2
  161. %>
  162. </TABLE>
  163. <FORM ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>" METHOD="post">
  164. <INPUT TYPE="hidden" NAME="m" VALUE="<%= intMaand %>">
  165. <INPUT TYPE="hidden" NAME="y" VALUE="<%= intJaar %>">
  166. <INPUT TYPE="submit" NAME="action" VALUE="previous">
  167. <INPUT TYPE="submit" NAME="action" VALUE="next">
  168. </FORM>
  169. </BODY>
  170. </HTML>
Download code! Download code (.txt)

 Bekijk een voorbeeld van dit script!
 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (1)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.028s