this is part of a calendar i'm writing, the problem is i can't display the event for the current date unless the event is placed at the top of the database list. Please help. Its written as javascript and saved as .jsp file.
//starts here
calendar += "<table width='100%' border='0' cellpadding='2' cellspacing='1'>";
calendar += "<tr>";
if(startday > 0) {
for(empty = 0; empty < startday; empty++) {
calendar += "<td width='" + twidth + "' height='" + theight + "'> </td>";
}
}
for(i = startday; i <= endday; i++) {
if( (i % 7) == 0) {
calendar += "</tr><tr>";
}
//keep highlight info on the current month and day
if( (i - (startday - 1)) == dt && currentmonth == mo && currentyear == year) {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + "><b>";
calendar += "<a href='javascript://' onclick=javascriptpen_window('day_schedule.jsp?" + months[mo] + "&" + count + "',500,350,0,1);><font color=" + sdaycol + ">" + count + "</font></a>";
<%
if(RS.next()){
month=RS.getString("date_format(date,'%M')"
date=RS.getString("date_format(date,'%d')"
ev=RS.getString("event"
cat=RS.getString("category"
%>
var col;
if ((months[mo]=="<%=month%>"&&(count=="<%=date%>") {
if ("<%=cat%>"=="Leave"{col="aqua";}
if ("<%=cat%>"=="Company Trip"{col="cyan";}
if ("<%=cat%>"=="Gazetted Public Holidays"{col="cornsilk";}
if ("<%=cat%>"=="Annual Dinner"{col="lavender";}
if ("<%=cat%>"=="Meeting"{col="khaki";}
if ("<%=cat%>"=="Appointment"{col="lime";}
if ("<%=cat%>"=="ISO"{col="linen";}
if ("<%=cat%>"=="Seminar"{col="ivory";}
if ("<%=cat%>"=="Training"{col="royalblue";}
if ("<%=cat%>"=="Others"{col="skyblue";}
calendar += "<table width=100%>";
calendar += "<tr bgcolor="+ col +"><td>";
calendar += "<font face=Arial size=1 color=#000000><%=ev%></font>";
calendar += "</td></tr>";
calendar += "</table>";
}
<%
}
%>
calendar += "</b></font></td>";
} else {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + ">";
calendar += "<a href='javascript://' onclick=javascriptpen_window('day_schedule.jsp?" + months[mo] + "&" + count + "',500,350,0,1);><font color=" + daycol + ">" + count + "</font></a>";
<%
while(RS.next()){
month=RS.getString("date_format(date,'%M')"
date=RS.getString("date_format(date,'%d')"
ev=RS.getString("event"
cat=RS.getString("category"
%>
var col;
if ((months[mo]=="<%=month%>"&&(count=="<%=date%>"){
if ("<%=cat%>"=="Leave"{col="aqua";}
if ("<%=cat%>"=="Company Trip"{col="cyan";}
if ("<%=cat%>"=="Gazetted Public Holidays"{col="cornsilk";}
if ("<%=cat%>"=="Annual Dinner"{col="lavender";}
if ("<%=cat%>"=="Meeting"{col="khaki";}
if ("<%=cat%>"=="Appointment"{col="lime";}
if ("<%=cat%>"=="ISO"{col="linen";}
if ("<%=cat%>"=="Seminar"{col="ivory";}
if ("<%=cat%>"=="Training"{col="royalblue";}
if ("<%=cat%>"=="Others"{col="skyblue";}
calendar += "<table width=100%>";
calendar += "<tr bgcolor="+ col +"><td>";
calendar += "<font face=Arial size=1 color=#000000><%=ev%></font>";
calendar += "</td></tr>";
calendar += "</table>";
}
<%
}
%>
calendar += "</font></td>";
}
count++;
}
calendar += "</tr>";
calendar += "</table>";
//starts here
calendar += "<table width='100%' border='0' cellpadding='2' cellspacing='1'>";
calendar += "<tr>";
if(startday > 0) {
for(empty = 0; empty < startday; empty++) {
calendar += "<td width='" + twidth + "' height='" + theight + "'> </td>";
}
}
for(i = startday; i <= endday; i++) {
if( (i % 7) == 0) {
calendar += "</tr><tr>";
}
//keep highlight info on the current month and day
if( (i - (startday - 1)) == dt && currentmonth == mo && currentyear == year) {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + "><b>";
calendar += "<a href='javascript://' onclick=javascriptpen_window('day_schedule.jsp?" + months[mo] + "&" + count + "',500,350,0,1);><font color=" + sdaycol + ">" + count + "</font></a>";
<%
if(RS.next()){
month=RS.getString("date_format(date,'%M')"
date=RS.getString("date_format(date,'%d')"
ev=RS.getString("event"
cat=RS.getString("category"
%>
var col;
if ((months[mo]=="<%=month%>"&&(count=="<%=date%>") {
if ("<%=cat%>"=="Leave"{col="aqua";}
if ("<%=cat%>"=="Company Trip"{col="cyan";}
if ("<%=cat%>"=="Gazetted Public Holidays"{col="cornsilk";}
if ("<%=cat%>"=="Annual Dinner"{col="lavender";}
if ("<%=cat%>"=="Meeting"{col="khaki";}
if ("<%=cat%>"=="Appointment"{col="lime";}
if ("<%=cat%>"=="ISO"{col="linen";}
if ("<%=cat%>"=="Seminar"{col="ivory";}
if ("<%=cat%>"=="Training"{col="royalblue";}
if ("<%=cat%>"=="Others"{col="skyblue";}
calendar += "<table width=100%>";
calendar += "<tr bgcolor="+ col +"><td>";
calendar += "<font face=Arial size=1 color=#000000><%=ev%></font>";
calendar += "</td></tr>";
calendar += "</table>";
}
<%
}
%>
calendar += "</b></font></td>";
} else {
calendar += "<td width='" + twidth + "' height='" + theight + "' bgcolor='" + daybg + "' align='right' valign='top'><font face='" + dayfam + "' size=" + daysize + ">";
calendar += "<a href='javascript://' onclick=javascriptpen_window('day_schedule.jsp?" + months[mo] + "&" + count + "',500,350,0,1);><font color=" + daycol + ">" + count + "</font></a>";
<%
while(RS.next()){
month=RS.getString("date_format(date,'%M')"
date=RS.getString("date_format(date,'%d')"
ev=RS.getString("event"
cat=RS.getString("category"
%>
var col;
if ((months[mo]=="<%=month%>"&&(count=="<%=date%>"){
if ("<%=cat%>"=="Leave"{col="aqua";}
if ("<%=cat%>"=="Company Trip"{col="cyan";}
if ("<%=cat%>"=="Gazetted Public Holidays"{col="cornsilk";}
if ("<%=cat%>"=="Annual Dinner"{col="lavender";}
if ("<%=cat%>"=="Meeting"{col="khaki";}
if ("<%=cat%>"=="Appointment"{col="lime";}
if ("<%=cat%>"=="ISO"{col="linen";}
if ("<%=cat%>"=="Seminar"{col="ivory";}
if ("<%=cat%>"=="Training"{col="royalblue";}
if ("<%=cat%>"=="Others"{col="skyblue";}
calendar += "<table width=100%>";
calendar += "<tr bgcolor="+ col +"><td>";
calendar += "<font face=Arial size=1 color=#000000><%=ev%></font>";
calendar += "</td></tr>";
calendar += "</table>";
}
<%
}
%>
calendar += "</font></td>";
}
count++;
}
calendar += "</tr>";
calendar += "</table>";