Jump to content

calendar


andre@oriontech.no

Recommended Posts

What are you having trouble with?
In my DB, the date is like this. 9.5.2008. This means 9 of may 2008.But how coult i use it too show it like the pink box? So when I push the buttom, the stored message showes up.The code looks like this:<%pDay = Request.QueryString("d")pMonth = Request.QueryString("m")pYear = Request.QueryString("y")Pdate = Request.QueryString("date")thedate = NOW()pAvtale = "15.5.2008"pAv = "André Brandtzæg"pBG = "#33FF00"pSub = "Lønn"pKlSt = "8"pKlSp = "16"Function GetDaysInMonth(iMonth, iYear) Dim dTemp dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1)) GetDaysInMonth = Day(dTemp)End Function' Previous implementation of GetDaysInMonthFunction GetDaysInMonth(iMonth, iYear) Select Case iMonth Case 1, 3, 5, 7, 8, 10, 12 GetDaysInMonth = 31 Case 4, 6, 9, 11 GetDaysInMonth = 30 Case 2 If IsDate("February 29, " & iYear) Then GetDaysInMonth = 29 Else GetDaysInMonth = 28 End If End SelectEnd FunctionFunction GetWeekdayMonthStartsOn(dAnyDayInTheMonth) Dim dTemp dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 0), dAnyDayInTheMonth) GetWeekdayMonthStartsOn = WeekDay(dTemp)End FunctionFunction SubtractOneMonth(dDate) SubtractOneMonth = DateAdd("m", -1, dDate)End FunctionFunction AddOneMonth(dDate) AddOneMonth = DateAdd("m", 1, dDate)End FunctionDim dDate ' Date we're displaying calendar forDim iDIM ' Days In MonthDim iDOW ' Day Of Week that month starts onDim iCurrent ' Variable we use to hold current day of month as we write tableDim iPosition ' Variable we use to hold current position in tableDim iLooper ' Variable used for misc. loops' Get selected date. There are two ways to do this.' First check if we were passed a full date in RQS("date").' If so use it, if not look for seperate variables, putting them togeter into a date.' Lastly check if the date is valid...if not use todayIf IsDate(Request.QueryString("date")) Then dDate = CDate(Request.QueryString("date"))Else If IsDate(Request.QueryString("day") & "." & Request.QueryString("month") & "." & Request.QueryString("year")) Then dDate = CDate(Request.QueryString("day") & "." & Request.QueryString("month") & "." & Request.QueryString("year")) Else dDate = Date() ' The annoyingly bad solution for those of you running IIS3 If Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then Response.Write "Datoen du valgte er feil.<br>Kalenderen ble satt til dagens dato.<BR>" End If ' The elegant solution for those of you running IIS4 'If Request.QueryString.Count <> 0 Then Response.Write "Datoen du valgte er feil.<br>Kalenderen ble satt til dagens dato.<BR>" End IfEnd If'Now we've got the date. Now get Days in the choosen month and the day of the week it starts on.iDIM = GetDaysInMonth(Month(dDate), Year(dDate))iDOW = GetWeekdayMonthStartsOn(dDate)%><table border="0" cellpadding="0" cellspacing="1" width="100%" id="table3" style="margin: 0px" height="483"> <tr> <td width="152" valign="top" style="border-left: 0.2pt solid windowtext; border-right: 0.2pt solid windowtext; border-top: 0.2pt solid windowtext; border-bottom: 0.2pt solid windowtext; border-color: #7C7C94;"><center><span style="font-size: 2pt"> </span><table cellSpacing="0" cellPadding="1" width="140" bgColor="#ffffff" border="0" id="table5"> <tr bgColor="#D7D7E5"> <td height="10px" class="SOME" vAlign="center" align="left"> <a href="cal_oppdater_form.asp?date=<%= SubtractOneMonth(dDate) %>"> <img height="7" alt="Previous Month" src="../bilder/prev.gif" width="4" border="0"></a> </td> <td class="SOME" vAlign="center" align="middle" height="10px" colspan="5"> <strong><%= MonthName(Month(dDate)) & " " & Year(dDate) %></strong> </td> <td height="10px" class="SOME" vAlign="center" align="right"> <A HREF="cal_oppdater_form.asp?date=<%= AddOneMonth(dDate) %>" class="NOEVENT"> <img height="7" alt="Next Month" src="../bilder/next.gif" width="4" border="0"></a> </td> </tr> <tr> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">M</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">T</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">O</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">T</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">F</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">L</td> <td class="SOME" vAlign="bottom" align="center" width="20" height="15" style="border-bottom: 1.0pt solid windowtext;">S</td> </tr><%' Write spacer cells at beginning of first row if month doesn't start on a Sunday.If iDOW <> 1 Then%> <tr><% iPosition = 1 Do While iPosition < iDOW%> <td height="10px" class="SOME"> </td><% iPosition = iPosition + 1 LoopEnd If' Write days of month in proper day slotsiCurrent = 1iPosition = iDOWDo While iCurrent <= iDIM ' If we're at the begginning of a row then write TR If iPosition = 1 Then%> <tr><% End If ' If the day we're writing is the selected day then highlight it somehow. If iCurrent&"."&Month(dDate)&"."&Year(dDate) = pAvtale Then %> <td height="10px" class="SOME" align="right" bgcolor="#00FFFF" style="border-left: 0.2pt solid windowtext; border-right: 0.2pt solid windowtext; border-top: 0.2pt solid windowtext; border-bottom: 0.2pt solid windowtext; border-color: #BB5503;"><a href="cal_oppdater_form.asp?date=<%=iCurrent%>.<%=Month(dDate)%>.<%=Year(dDate)%>" class="NOEVENT"><b><i><%=iCurrent%></i></b></td> <% Elseif iCurrent = Day(thedate) Then %> <td height="10px" class="SOME" align="right" bgcolor="#FBE694" style="border-left: 0.2pt solid windowtext; border-right: 0.2pt solid windowtext; border-top: 0.2pt solid windowtext; border-bottom: 0.2pt solid windowtext; border-color: #BB5503;"><b><i><%=iCurrent%></i></b></td> <% Elseif iCurrent = Day(dDate) Then %> <td class="SOME" align="right" bgcolor="#FF00FF" style="border-left: 0.2pt solid windowtext; border-right: 0.2pt solid windowtext; border-top: 0.2pt solid windowtext; border-bottom: 0.2pt solid windowtext; border-color: #BB5503;"><%=iCurrent%></td> <% Else %> <td height="10px" class="SOME" align="right"><a href="cal_new_form.asp?date=<%=iCurrent%>.<%=Month(dDate)%>.<%=Year(dDate)%>" class="NOEVENT"><%=iCurrent%></a></td> <% End If ' If we're at the endof a row then write /TR If iPosition = 7 Then%></tr><% iPosition = 0 End If ' Increment variables iCurrent = iCurrent + 1 iPosition = iPosition + 1Loop' Write spacer cells at end of last row if month doesn't end on a Saturday.If iPosition <> 1 Then Do While iPosition <= 7 %> <td height="10px" class="SOME"> </td> <% iPosition = iPosition + 1 Loop %> </tr><%End If%></table>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...