PDA

View Full Version : CSS Styling an ASP/VBScript Calendar


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%>&nbsp;<%=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>

BaldEagle
10-18-2005, 06:04 PM
I don't see where you are advancing your recordset.

BaldEagle

Deanoo
10-19-2005, 09:32 AM
Thanks for the reply BaldEagle, I managed to get it working last night. Started again and, as you point out, noticed I wasn't paging through the recordset.

Code that works now is below:

<tr>
<% Do while weekCount <= 7
dateSelect = navmonth & "/" & dateCounter & "/" & navyear %>

<% If (weekCount < firstDay) OR (dateCounter > lastDate) Then %>
<td height="60px"><img src="im/clear.gif" height="1" width="1"></td>
<% else %>
<td height="60px" valign="top" class="

<%
Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open "SELECT * FROM Events", Conn, 1, 3
Do while NOT RSEVENT.EOF
rsdate = RSEVENT("Date")
rscat = RSEVENT("Category")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(navmonth)) AND (Year(rsdate) = CInt(navyear)) Then%>
<%If RSBODY("Event_Display") = True Then%>
<%=RSEVENT("Category")%>
<% End If
Else %>
lowrate
<%End If
RSEVENT.movenext
Loop
RSEVENT.close
%>

"><%=dateCounter%></td>



<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
</tr>