Deanoo
10-17-2005, 01:58 PM
Hello all,
I am working on a simple online reservation system which allows me to show available/unavailable dates on a calender. The calender is written in VBScript but the underlying data is held on a database. I have a number of CSS classes to style the cells.
The problem I have is this:
Only the first entry in the database is being acted upon (i.e, cell style applied). Can anyone point out where I am going wrong? Code is as follows:
<%
EventDate = date
CurrentMonth = Month(EventDate)
CurrentMonthName = MonthName(CurrentMonth)
CurrentYear = Year(EventDate)
%>
<table cols="7" border="0" cellspacing="3">
<tr> <!--This TR will show the main heding with the Month Name in it -->
<td colspan="7" align="center">
<%=CurrentMonthName%> <%=CurrentYear%>
</td>
</tr>
<tr> <!-- This TR will output the names of the days of the week -->
<%
For DayLoop = 1 to 7
%>
<td class="weekday">
<%=WeekDayName(DayLoop, True, 0)%>
</td>
<%
Next
%>
</tr>
<%
FirstDayDate = DateSerial(CurrentYear, CurrentMonth, 1)
FirstDay = WeekDay(FirstDayDate,0)
CurrentDay = FirstDayDate
%>
<%If FirstDay <> 1 Then%>
<td colspan="<%=FirstDay -1 %>">
<%End If%>
</td>
<%DayCounter = FirstDay
CorrectMonth = True%>
<% Do While CorrectMonth = True %>
<% If CurrentDay = rsEvents("EventDate") Then %>
<td width="75px" height="60px" valign="top" class="
<%If rsEvents("EventCat") = "Provisional" Then %>
provisional
<% Elseif rsEvents("EventCat") = "Confirmed" Then %>
confirmed
<% Elseif rsEvents("EventCat") = "High" Then %>
highrate
<% End if %>
">
<% Else %>
<td width="75px" height="60px" valign="top" class="lowrate" style="filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;">
<% end if%>
<%=Day(CurrentDay)%>
</td>
<%
DayCounter = DayCounter +1
if DayCounter >7 Then
DayCounter = 1
%>
</tr><tr>
<% End If
CurrentDay = DateAdd("d", 1, CurrentDay)
If Month(CurrentDay) <> CurrentMonth Then
CorrectMonth = False
End If
Loop
%>
<%
If DayCounter <> 1 Then %>
<td colspan ="<%=8-DayCounter%>">
</td>
<% End If %>
</tr>
</table>
I am working on a simple online reservation system which allows me to show available/unavailable dates on a calender. The calender is written in VBScript but the underlying data is held on a database. I have a number of CSS classes to style the cells.
The problem I have is this:
Only the first entry in the database is being acted upon (i.e, cell style applied). Can anyone point out where I am going wrong? Code is as follows:
<%
EventDate = date
CurrentMonth = Month(EventDate)
CurrentMonthName = MonthName(CurrentMonth)
CurrentYear = Year(EventDate)
%>
<table cols="7" border="0" cellspacing="3">
<tr> <!--This TR will show the main heding with the Month Name in it -->
<td colspan="7" align="center">
<%=CurrentMonthName%> <%=CurrentYear%>
</td>
</tr>
<tr> <!-- This TR will output the names of the days of the week -->
<%
For DayLoop = 1 to 7
%>
<td class="weekday">
<%=WeekDayName(DayLoop, True, 0)%>
</td>
<%
Next
%>
</tr>
<%
FirstDayDate = DateSerial(CurrentYear, CurrentMonth, 1)
FirstDay = WeekDay(FirstDayDate,0)
CurrentDay = FirstDayDate
%>
<%If FirstDay <> 1 Then%>
<td colspan="<%=FirstDay -1 %>">
<%End If%>
</td>
<%DayCounter = FirstDay
CorrectMonth = True%>
<% Do While CorrectMonth = True %>
<% If CurrentDay = rsEvents("EventDate") Then %>
<td width="75px" height="60px" valign="top" class="
<%If rsEvents("EventCat") = "Provisional" Then %>
provisional
<% Elseif rsEvents("EventCat") = "Confirmed" Then %>
confirmed
<% Elseif rsEvents("EventCat") = "High" Then %>
highrate
<% End if %>
">
<% Else %>
<td width="75px" height="60px" valign="top" class="lowrate" style="filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;">
<% end if%>
<%=Day(CurrentDay)%>
</td>
<%
DayCounter = DayCounter +1
if DayCounter >7 Then
DayCounter = 1
%>
</tr><tr>
<% End If
CurrentDay = DateAdd("d", 1, CurrentDay)
If Month(CurrentDay) <> CurrentMonth Then
CorrectMonth = False
End If
Loop
%>
<%
If DayCounter <> 1 Then %>
<td colspan ="<%=8-DayCounter%>">
</td>
<% End If %>
</tr>
</table>