rudyflyer
asked on
ASP - Get Current Month, Current Year number then navigate between months
Hello,
I have a Web page called "month.asp". I am wanting to list the current month and Year (i.e Septemeber, 2004). Then I will want to write it. Then, next to the month name will be two graphic arrows that will allow a user to navigate to the previous month or to the next month while staying on "month.asp".
This is not a calendar. I am just looking to navigate through the months.
Can you please help with a code example?
Thank you in advance.
I have a Web page called "month.asp". I am wanting to list the current month and Year (i.e Septemeber, 2004). Then I will want to write it. Then, next to the month name will be two graphic arrows that will allow a user to navigate to the previous month or to the next month while staying on "month.asp".
This is not a calendar. I am just looking to navigate through the months.
Can you please help with a code example?
Thank you in advance.
much cleaner version:
<%
Dim sDate
Dim sCurrMonth
Dim sBackMonthVal
Dim sForwardMonthVal
sDisplayMonth = ""
sDate = date()
sCurrMonth = Month(date())
if len(request("currmonth"))> 0 then
sCurrMonth = request("currmonth")
end if
if sDisplayMonth="" then
sDisplayMonth = sCurrMonth
end if
if sDisplayMonth<1 then
sDisplayMonth=12
end if
if sDisplayMonth>12 then
sDisplayMonth=1
end if
sBackMonthVal = sCurrMonth-1
sForwardMonthVal = sCurrMonth+1
if sBackMonthVal<1 then sBackMonthVal=12
if sForwardMonthVal>12 then sForwardMonthVal=1
%>
<a href="month.asp?currmonth= <%=sBackMo nthVal%>"> <-- </a><%=MonthName(sDisplayM onth)%><a href="month.asp?currmonth= <%=sForwar dMonthVal% >"> --> </a>
<%
Dim sDate
Dim sCurrMonth
Dim sBackMonthVal
Dim sForwardMonthVal
sDisplayMonth = ""
sDate = date()
sCurrMonth = Month(date())
if len(request("currmonth"))>
sCurrMonth = request("currmonth")
end if
if sDisplayMonth="" then
sDisplayMonth = sCurrMonth
end if
if sDisplayMonth<1 then
sDisplayMonth=12
end if
if sDisplayMonth>12 then
sDisplayMonth=1
end if
sBackMonthVal = sCurrMonth-1
sForwardMonthVal = sCurrMonth+1
if sBackMonthVal<1 then sBackMonthVal=12
if sForwardMonthVal>12 then sForwardMonthVal=1
%>
<a href="month.asp?currmonth=
ASKER
peh803,
This is excellent. One other thing if you don't mind. Is it possible to also get the year? So, when a user navigates from month to month a parameter is passed indicating the year. Then, when to gets to January the year changes to the next year.
THanks a lot.
This is excellent. One other thing if you don't mind. Is it possible to also get the year? So, when a user navigates from month to month a parameter is passed indicating the year. Then, when to gets to January the year changes to the next year.
THanks a lot.
hm, okay, I should be able to include that (although it wasn't part of the original specifications....).
Give me a minute.
Also, I'd be glad to accept more points for the additional question (2 for 1) :)
Glad you're happy so far,
peh803
Give me a minute.
Also, I'd be glad to accept more points for the additional question (2 for 1) :)
Glad you're happy so far,
peh803
ASKER
peh803,
Opps. I meant to increase the points. Sorry about that. I doubled it to 250.
Opps. I meant to increase the points. Sorry about that. I doubled it to 250.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
peh803,
Thanks a lot for the speedy replys and the help. Much appreciated.
Thanks a lot for the speedy replys and the help. Much appreciated.
no problem at all...always glad to help.
Take care, and look me up for future ?'s!
peh803
Take care, and look me up for future ?'s!
peh803
regards,
peh803
<%
Dim sDate
Dim sCurrMonth
Dim sForward
Dim sBack
Dim sBackMonthVal, sForwardMonthVal
sBack = ""
sForward = ""
sDisplayMonth = ""
if len(trim(request("forward"
sForward = request("forward")
end if
if len(trim(request("back")))
sBack = request("back")
end if
sDate = date()
sCurrMonth = Month(date())
if len(request("currmonth"))>
sCurrMonth = request("currmonth")
end if
if sBack<>"" then
' sDisplayMonth = sCurrMonth-1
end if
if sForward<>"" then
' sDisplayMonth = sCurrMonth+1
end if
if sDisplayMonth="" then
sDisplayMonth = sCurrMonth
end if
if sDisplayMonth<1 then
sDisplayMonth=12
end if
if sDisplayMonth>12 then
sDisplayMonth=1
end if
sBackMonthVal = sCurrMonth-1
sForwardMonthVal = sCurrMonth+1
if sBackMonthVal<1 then sBackMonthVal=12
if sForwardMonthVal>12 then sForwardMonthVal=1
%>
<a href="month.asp?back=1&cur