Click to See Complete Forum and Search --> : Amending variables through links


nookiemon
04-24-2006, 04:16 PM
Hi, I'm looking for help on getting a dynamic schedule. Basically, the page will open with todays date and the events. It formats the tabs depending on what day today is and pulls the data off my database using sql.

So I've managed to get that part done. See http://www.graemejones.co.uk/ASP/life/whatson.asp.

The next part I'm stuck with is how to get my date variables to change using the links i.e. if I click on tues it adds 1 day to my variable, wed 1 days, or one week 7.

Here are my variables used and their functions

This part will pull up the info for the adjusted date


<% Dim DateToday
DateToday = date()%>



sSQL="SELECT schedules.Date, schedules.Time, schedules.Show FROM schedules WHERE (((schedules.Date)=#" & DateToday & "#))"


Sorts out the info re schedule for today


<%
Dim strDay
Dim strMonth
strDay=(weekday(date))
Select Case strDay
case 1 Response.write("Sunday")
case 2 Response.write("Monday")
case 3 Response.write("Tuesday")
case 4 Response.write("Wednesday")
case 5 Response.write("Thursday")
case 6 Response.write("Friday")
case 7 Response.write("Saturday")
End Select
Response.Write(" "&day(date)&" ")

strMonth=(month(date))
Select Case strMonth
case 1 Response.write("January")
case 2 Response.write("February")
case 3 Response.write("March")
case 4 Response.write("April")
case 5 Response.write("May")
case 6 Response.write("June")
case 7 Response.write("July")
case 8 Response.write("August")
case 9 Response.write("September")
case 10 Response.write("October")
case 11 Response.write("November")
case 12 Response.write("December")
End Select
%>


Sorts out my css for the tabs


<%
Dim dayNo
dayNo=(weekday(date)) %>



<li><%
If dayNo=2 Then
response.write "<span>MON</span>"
Else
response.write "<a href='#'>MON</a>"
End If
%> </li>



I hope i explained myself well and would appreciate some advice.

Many thanks

lmf232s
04-24-2006, 04:32 PM
in the links for the tabs all you need to do to increament them is something like this.

<a href="MyPage.asp?sDate=<%=DateAdd("d", 1, Date)%>">

This will take todays date and add 1 to it giving you tomorrow.
I assume your creating your tabs in some kind of a loop. So instead of using a number, use the variables that gets increamented on each loop.

nookiemon
04-24-2006, 04:39 PM
Hi lmf232s, thanks for the reply

assume your creating your tabs in some kind of a loop. So instead of using a number, use the variables that gets increamented on each loop.

My tabs are static, i.e. simple list created with each <li> having the asp.

Will this cause a problem with the strings you used? I'm not really clued up on the whole MyPage.asp?

Many thanks

lmf232s
04-24-2006, 05:01 PM
nook,
Mypage.asp is not a realy page just a fake link i put in there. The important part was
DateAdd("d", 1, Date())
Which will take todays date and add 1 to it. I would loop your <li> elements like this.


Response.Write "<ul>"
For i = 0 to 6
Response.write "<li><a href=""YourPage.asp?sDate=" & DateAdd("d", i, Date) & """>" & GetDay(i) & "</a></li>
Next
Response.Write "</ul>"



Where GetDay is a function that goes and gets the correct day (mon, tue, wed) based on the number you pass in where 0 = Mon, 1 = Tue, etc.

Although i dont think this will work for everyday of the week. This should only work if its a monday.

You going to have to use the dateaddfunction w/ another date function embedded in it and you need to see if the current date <> Monday. Then based on that information youll either add or subtrack to todays date to get the links you need. I dont know exaclty the formula that you need to do this but ill play around w/ it. Im sure someone will beat me to it.