Author |
Topic  |
|
Bookie
Average Member
  
USA
856 Posts |
Posted - 10 July 2001 : 20:17:31
|
Ok. I've got the idea and I know how it should work but I need help writing the code.
I'm adding two form fields to the form to submit events to a calendar... recur_num and recur_freq. Recur_num is the number of times you want to repeat the event. Recur_freq is the frequency you want to repeat it (daily-1, weekly-7, monthly-??, yearly-365).
For as many times as I want to repeat the event it will loop through and execute another sql string. Each time it executes the string, it will add 1, 7, or 365 days to the date. I've figured out how to add days to the start date but I just need some help with the loop.
----------------------------------------------------------- If sUpdateMode = "edit" Then sSQL = "UPDATE " & strTablePrefix & "EVENTS SET Start_Date = '" & DateToStr(Request.Form("START_DATE")) & "', End_Date = '" & DateToStr(enddate) & "', Event_Title = '" & chkstring(Request.Form("EVENT_TITLE"), "message") & "',PRIVATE = " & intPrivateEvent sSQL = sSQL & ", Event_Details = '" & chkstring(Request.Form("Message"), "message") & "', date_added = '" & DateToStr(now()) & "' WHERE Event_ID=" & Request.Form("Event_ID") my_Conn.Execute sSQL Else sSQL = "INSERT INTO " & strTablePrefix & "EVENTS (Start_Date, End_Date, Event_Title, Event_Details, Date_Added, Added_by, PRIVATE) Values ('" & DateToStr(Request.Form("START_DATE")) & "', '" & DateToStr(enddate) & "',' " & chkstring(Request.Form("EVENT_TITLE"), "message") & "', '" & chkstring(Request.Form("Message"), "message") & "', '" & DateToStr(now()) & "', " & memberid & "," & intPrivateEvent & ")" ' response.write(sSQL) ' response.write("<BR>"&DateToStr(cDate(Request.Form("start_date"))+7)) // This works!! ' my_Conn.Execute sSQL '#################### if NOT Request.Form("recur_num") = "0" then Dim recur_freq recur_freq = Request.Form("recur_freq") i=i+1 ' start of loop (loop as many times as recur_num) sSQL+i = "INSERT INTO " & strTablePrefix & "EVENTS (Start_Date, End_Date, Event_Title, Event_Details, Date_Added, Added_by, PRIVATE) Values ('" & DateToStr(cDate(Request.Form("START_DATE"))+recur_freq)) & "', '" & DateToStr(cDate(Request.Form("END_DATE"))+recur_freq) & "',' " & chkstring(Request.Form("EVENT_TITLE"), "message") & "', '" & chkstring(Request.Form("Message"), "message") & "', '" & DateToStr(now()) & "', " & memberid & "," & intPrivateEvent & ")" my_Conn.Execute sSQL+i loop end if '#################### End If -----------------------------------------------------------
Help??
Bookie
"May the forces of evil become confused on the way to your home." - George Carlin
Edited by - Bookie on 10 July 2001 20:20:50 |
|
Bookie
Average Member
  
USA
856 Posts |
Posted - 10 July 2001 : 21:25:23
|
I've figured out a basic addition to accomplish an event recurrance. However, I would not recommend this as a mod add-on until other people look over the code and make appropriate changes.
For example, for this to work effectively, a person would want to repeat a monthly event on the same date. Since I have this adding days to the date, I'm not able to add a month because a month may be 28, 30, or 31 days. Same with a leap year. If someone can figure this out, let me know. Perhaps there are other issues to consider that I don't know about.
Take a look at the code. There are two things you would need to add to the events_functions.asp page. You should be able to find the spots and add the code.
http://www.bookfamily.net/forum/event_recur.txt
Bookie
"May the forces of evil become confused on the way to your home." - George Carlin |
 |
|
bjlt
Senior Member
   
1144 Posts |
Posted - 10 July 2001 : 22:20:49
|
I'm sure you can find a function for recuring date in month. Just search around in the asp resources. I'm looking for it now. will post here if i found any.
here's an example. http://baltimores.inyourtown.com/event/eventsubmit.asp?m=27
Edited by - bjlt on 10 July 2001 22:34:32 |
 |
|
|
Topic  |
|
|
|