asp calendar help

Discussion in 'ASP General' started by Risikio, Jan 11, 2006.

  1. Risikio

    Risikio Guest

    Not sure if I am in the right forum/area. I am looking for some help with
    writing an .asp code. I was given an .asp code for an editable calendar, that
    I think was downloaded from one of those free code websites. I am new to .asp
    code, so I am asking for help. The code allows only one event per date to be
    added to the calendar, and I need to make the code work for up to three
    events per date. I have tried looping the code, but can not get it to read
    the second event for a particular date from the MS Access database table. Any
    help would be greatly appreciated. I have already spent more time on this
    than I can afford to. Here is the code. Thanks.


    <!--#include file = "database.inc" -->
    <%
    i = 0
    iLastDay = LastDay(iYear, iMonth)
    iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
    iLastDay = iFirstDay + iLastDay - 1

    do while i<= iLastDay
    if i <> iLastDay then
    Response.Write ("<tr>")
    else
    exit do
    end if
    for j=1 to 7

    if (j < iFirstDay and i = 0) or (i + j > iLastDay) then

    Response.Write ("<td width='90' height='75' valign='top' bgcolor='#000080'
    NOWRAP></td>")
    else
    k = k + 1
    sDate = "#" & iMonth & "/" & k & "/" & iYear & "#"
    set rs = conn.execute("SELECT * FROM EVENTS WHERE DATE = " & sDate)
    if rs.eof then
    sHREF = "AddEvent.asp"
    sEvent = ""
    else
    sHREF = "EditEvent.asp"
    sEvent = "&nbsp;<P><FONT SIZE=-2 FACE='Arial,Helvetica'><A HREF =
    'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") & "</A><BR>"
    if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
    if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
    sEvent = sEvent & "</FONT>"
    End If
    sHREF = sHREF & "?Month=" & iMonth & "&Day=" & k & "&Year=" & iYear
    Response.Write ("<td width='90' height='75' valign='top'>")
    Response.Write "<B>"
    Response.write k & "</A></B>" & sEvent
    Response.Write ("</td>")
    end if

    next
    i=i+7

    loop
    Response.Write ("</tr>")
    %>
    <!--#include file = "database_cleanup.inc"-->
    Risikio, Jan 11, 2006
    #1
    1. Advertising

  2. Risikio

    Paxton Guest

    Risikio wrote:
    > Not sure if I am in the right forum/area. I am looking for some help with
    > writing an .asp code. I was given an .asp code for an editable calendar, that
    > I think was downloaded from one of those free code websites. I am new to .asp
    > code, so I am asking for help. The code allows only one event per date to be
    > added to the calendar, and I need to make the code work for up to three
    > events per date. I have tried looping the code, but can not get it to read
    > the second event for a particular date from the MS Access database table. Any
    > help would be greatly appreciated. I have already spent more time on this
    > than I can afford to. Here is the code. Thanks.
    >
    >
    > <!--#include file = "database.inc" -->
    > <%
    > i = 0
    > iLastDay = LastDay(iYear, iMonth)
    > iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
    > iLastDay = iFirstDay + iLastDay - 1
    >
    > do while i<= iLastDay
    > if i <> iLastDay then
    > Response.Write ("<tr>")
    > else
    > exit do
    > end if
    > for j=1 to 7
    >
    > if (j < iFirstDay and i = 0) or (i + j > iLastDay) then
    >
    > Response.Write ("<td width='90' height='75' valign='top' bgcolor='#000080'
    > NOWRAP></td>")
    > else
    > k = k + 1
    > sDate = "#" & iMonth & "/" & k & "/" & iYear & "#"
    > set rs = conn.execute("SELECT * FROM EVENTS WHERE DATE = " & sDate)
    > if rs.eof then
    > sHREF = "AddEvent.asp"
    > sEvent = ""
    > else
    > sHREF = "EditEvent.asp"
    > sEvent = "&nbsp;<P><FONT SIZE=-2 FACE='Arial,Helvetica'><A HREF =
    > 'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") & "</A><BR>"
    > if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
    > if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
    > sEvent = sEvent & "</FONT>"
    > End If
    > sHREF = sHREF & "?Month=" & iMonth & "&Day=" & k & "&Year=" & iYear
    > Response.Write ("<td width='90' height='75' valign='top'>")
    > Response.Write "<B>"
    > Response.write k & "</A></B>" & sEvent
    > Response.Write ("</td>")
    > end if
    >
    > next
    > i=i+7
    >
    > loop
    > Response.Write ("</tr>")
    > %>
    > <!--#include file = "database_cleanup.inc"-->


    You have to use the movenext method to write out more than one record
    (if there is more than one record in the recordset in the first place)

    .....amended code....

    else

    sEvent = ""
    do until rs.eof

    sHREF = "EditEvent.asp"

    sEvent = sEvent & "&nbsp;<P><FONT SIZE=-2 FACE='Arial,Helvetica'><A
    HREF =
    'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") &
    "</A><BR>"

    if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
    if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")

    sEvent = sEvent & "</FONT>"

    rs.movenext
    loop
    End If

    /P.
    Paxton, Jan 11, 2006
    #2
    1. Advertising

  3. Risikio

    Risikio Guest

    Thank you very much! It works perfectly now.

    "Paxton" wrote:

    >
    > Risikio wrote:
    > > Not sure if I am in the right forum/area. I am looking for some help with
    > > writing an .asp code. I was given an .asp code for an editable calendar, that
    > > I think was downloaded from one of those free code websites. I am new to .asp
    > > code, so I am asking for help. The code allows only one event per date to be
    > > added to the calendar, and I need to make the code work for up to three
    > > events per date. I have tried looping the code, but can not get it to read
    > > the second event for a particular date from the MS Access database table. Any
    > > help would be greatly appreciated. I have already spent more time on this
    > > than I can afford to. Here is the code. Thanks.
    > >
    > >
    > > <!--#include file = "database.inc" -->
    > > <%
    > > i = 0
    > > iLastDay = LastDay(iYear, iMonth)
    > > iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
    > > iLastDay = iFirstDay + iLastDay - 1
    > >
    > > do while i<= iLastDay
    > > if i <> iLastDay then
    > > Response.Write ("<tr>")
    > > else
    > > exit do
    > > end if
    > > for j=1 to 7
    > >
    > > if (j < iFirstDay and i = 0) or (i + j > iLastDay) then
    > >
    > > Response.Write ("<td width='90' height='75' valign='top' bgcolor='#000080'
    > > NOWRAP></td>")
    > > else
    > > k = k + 1
    > > sDate = "#" & iMonth & "/" & k & "/" & iYear & "#"
    > > set rs = conn.execute("SELECT * FROM EVENTS WHERE DATE = " & sDate)
    > > if rs.eof then
    > > sHREF = "AddEvent.asp"
    > > sEvent = ""
    > > else
    > > sHREF = "EditEvent.asp"
    > > sEvent = "&nbsp;<P><FONT SIZE=-2 FACE='Arial,Helvetica'><A HREF =
    > > 'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") & "</A><BR>"
    > > if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
    > > if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
    > > sEvent = sEvent & "</FONT>"
    > > End If
    > > sHREF = sHREF & "?Month=" & iMonth & "&Day=" & k & "&Year=" & iYear
    > > Response.Write ("<td width='90' height='75' valign='top'>")
    > > Response.Write "<B>"
    > > Response.write k & "</A></B>" & sEvent
    > > Response.Write ("</td>")
    > > end if
    > >
    > > next
    > > i=i+7
    > >
    > > loop
    > > Response.Write ("</tr>")
    > > %>
    > > <!--#include file = "database_cleanup.inc"-->

    >
    > You have to use the movenext method to write out more than one record
    > (if there is more than one record in the recordset in the first place)
    >
    > .....amended code....
    >
    > else
    >
    > sEvent = ""
    > do until rs.eof
    >
    > sHREF = "EditEvent.asp"
    >
    > sEvent = sEvent & " <P><FONT SIZE=-2 FACE='Arial,Helvetica'><A
    > HREF =
    > 'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") &
    > "</A><BR>"
    >
    > if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
    > if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
    >
    > sEvent = sEvent & "</FONT>"
    >
    > rs.movenext
    > loop
    > End If
    >
    > /P.
    >
    >
    Risikio, Jan 11, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shevek
    Replies:
    3
    Views:
    6,011
    Shevek
    Jun 23, 2004
  2. tranky
    Replies:
    3
    Views:
    467
    Dave Johnson
    Aug 12, 2006
  3. Replies:
    3
    Views:
    591
    David Wier
    Sep 15, 2006
  4. Shevek
    Replies:
    0
    Views:
    373
    Shevek
    Jun 23, 2004
  5. Parthiv Joshi
    Replies:
    1
    Views:
    644
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page