Tools Links Login

Complete ASP Calendar

Displays a dynamic calendar in html using asp

Original Author: Matt Pantana

Inputs

You can input the month or the year, but neither is required

Assumptions

Just copy and paste the whole thing

Returns

a calendar

Side Affects

none

API Declarations

none: distribute freely

Code

<%
response.expires=0
dim CurMonth
dim CurDay
dim CurYear
dim NumOfDays
dim CurCell
dim onDay
dim FoundFirst
CurMonth = request.querystring("cmonth")
CurYear = request.querystring("cyear")
CurDay = request.querystring("cday")
if CurMonth = "" then curMonth = month(date)
if CurYear = "" then CurYear = year(date)
if CurDay = "" then CurDay = day(date)
FirstDay = weekday(CurMonth & "/01/" & CurYear)
cmonth = CurMonth
cyear = CurYear
NumOfDays = getlastday(cmonth,cyear)
FoundFirst = false
curcell = 1
onDay = 0
function GetLastDay( tmonth, tyear )
tmonth = tmonth + 1
if tmonth > 12 Then
tmonth = tmonth - 12
tyear = tyear + 1
End if
Dim x
x = DateAdd("d", -1, tmonth & "/01/" & tyear)
GetLastDay = Day( x )
End function

rows = 5
if firstday >= 5 and numofdays = 31 then
rows = 6
end if
if firstday >= 6 and numofdays = 30 then
rows = 6
end if

function DayOf()
if foundFirst then
onDay = OnDay + 1
if onDay > NumofDays then
DayOf = ""
else
DayOf = onDay
end if

else
if curcell = Firstday or firstday = 1 then foundfirst = true

if foundFirst then
onDay = OnDay + 1
if onDay > NumofDays then
DayOf = ""

else
DayOf = onDay

end if
else
DayOf = ""
end if

end if
  curcell = curcell + 1
if (OnDay + 1) = int(CurDay) and int(CurMonth) = int(month(date)) and int(CurYear) = year(date) then
bgcolor = "yellow"
else
bgcolor = ""
end if
end function
%>


Calendar








  

  

  

  



  

  

  

  



  

  

  

  



    
 
  
  

  
  
 
    











<% for i = 1 to rows %>









<% next %>

  
S


  
M


  
T


  
W


  
T


  
F


  
S


  
<%=DayOf%>


  
<%=DayOf%>


  
<%=DayOf%>


  
<%=DayOf%>


  
<%=DayOf%>


  
<%=DayOf%>


  
<%=DayOf%>




About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 115 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.