calendario en asp

lokeras
20 de Abril del 2004
Nacesito realizar un calendario en asp q me devuelva la fecha pulsada lo tendra q implementar en una web ya hecha.

Un Saludo:
Imanol Rivas

exnorlax
20 de Abril del 2004
hola yo tambien estoy interesado en el tema, si al guien tiene algun codigo haganmelo saber a mi email
[email protected]
si yo me entero de algo lo psteare aqui tambien
gracias

MiMoPa
20 de Abril del 2004
Aqui les va algo que encontre:


<%@ Language=VBScript %>
<%
'pagina que recibir la fecha seleccionada por el usuario
Const URLDestino = "OtraPagina.asp"

Dim MyMonth 'Month of calendar
Dim MyYear 'Year of calendar
Dim FirstDay 'First day of the month. 1 = Monday
Dim CurrentDay 'Used to print dates in calendar
Dim Col 'Calendar column
Dim Row 'Calendar row

MyMonth = Request.Querystring("Month")
MyYear = Request.Querystring("Year")

If IsEmpty(MyMonth) then MyMonth = Month(Date)
if IsEmpty(MyYear) then MyYear = Year(Date)

Call ShowHeader (MyMonth, MyYear)

FirstDay = WeekDay(DateSerial(MyYear, MyMonth, 1)) -1
CurrentDay = 1

'Let's build the calendar
For Row = 0 to 5
For Col = 0 to 6
If Row = 0 and Col < FirstDay then
response.write "<td>&nbsp;</td>"
elseif CurrentDay > LastDay(MyMonth, MyYear) then
response.write "<td>&nbsp;</td>"
else
response.write "<td"
if cInt(MyYear) = Year(Date) and cInt(MyMonth) = Month(Date) and CurrentDay = Day(Date) then
response.write " class='calCeldaResaltado' align='center'>"
else
response.write " align='center'>"
end if
response.write "<a href='" & URLDestino & "?day=" & CurrentDay _
& "&month=" & MyMonth & "&year=" & MyYear & "'>"
if cInt(MyYear) = Year(Date) and cInt(MyMonth) = Month(Date) and CurrentDay = Day(Date) then
Response.Write "<div class='calResaltado'>"
else
Response.Write "<div class='calSimbolo'>"
end if
Response.Write CurrentDay & "</div></a></td>"
CurrentDay = CurrentDay + 1
End If
Next
response.write "</tr>"
Next
response.write "</table></body></html>"


'------ Sub and functions


Sub ShowHeader(MyMonth,MyYear)
%>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<style>
.calFondoCalendario {background-color:cyan}
.calEncabe {font-family:Arial, Helvetica, sans-serif; font-size:11px}
.calFondoEncabe {background-color:lightgreen}
.calDias {font-family:Arial, Helvetica, sans-serif; font-size:9px; font-weight:900}
.calSimbolo {font-family:Arial, Helvetica, sans-serif; font-size:11px; text-decoration:none; font-weight:200; color:blue}
.calResaltado {font-family:Arial, Helvetica, sans-serif; font-size:11px; text-decoration:none; font-weight:700}
.calCeldaResaltado {background-color:lightyellow}
</style>
</head>

<body bgcolor='#FFFFFF'>

<table border='1' cellspacing='3' cellpadding='3' width='200' align='center' class="calFondoCalendario">
<tr align='center'>
<td colspan='7'>
<table border='0' cellspacing='1' cellpadding='1' width='100%' class="calFondoEncabe">
<tr>
<td align='left'>
<%
response.write "<a href = 'calendario2.asp?"
if MyMonth - 1 = 0 then
response.write "month=12&year=" & MyYear -1
else
response.write "month=" & MyMonth - 1 & "&year=" & MyYear
end if
response.write "'><span class='calSimbolo'><<</span></a>"

response.write "<span class='calEncabe'> <b>" & MonthName(MyMonth) & "</b> </span>"

response.write "<a href = 'calendario2.asp?"
if MyMonth + 1 = 13 then
response.write "month=1&year=" & MyYear + 1
else
response.write "month=" & MyMonth + 1 & "&year=" & MyYear
end if
response.write "'><span class='calSimbolo'>>></span></a>"
%>
</td>
<td align='center'>
<%
response.write "<a href = 'calendario2.asp?"
response.write "month=" & Month(Date()) & "&year=" & Year(Date())
response.write "'><div class='calSimbolo'><b>Hoy</b></div></a>"
%>
</td>
<td align='right'>
<%
response.write "<a href = 'calendario2.asp?"
response.write "month=" & MyMonth & "&year=" & MyYear -1
response.write "'><span class='calSimbolo'><<</span></a>"

response.write "<span class='calEncabe'> <b>" & MyYear & "</b> </span>"
response.write "<a href = 'calendario2.asp?"
response.write "month=" & MyMonth & "&year=" & MyYear + 1
response.write "'><span class='calSimbolo'>>></span></a>"
%>
</td>
</tr>
</table>
</td>
</tr>
<tr align='center'>
<td><div class='calDias'>D</div></td>
<td><div class='calDias'>L</div></td>
<td><div class='calDias'>M</div></td>
<td><div class='calDias'>X</div></td>
<td><div class='calDias'>J</div></td>
<td><div class='calDias'>V</div></td>
<td><div class='calDias'>S</div></td>
</tr>
<%
End Sub

Function MonthName(MyMonth)
Select Case MyMonth
Case 1
MonthName = "Enero"
Case 2
MonthName = "Febrero"
Case 3
MonthName = "Marzo"
Case 4
MonthName = "Abril"
Case 5
MonthName = "Mayo"
Case 6
MonthName = "Junio"
Case 7
MonthName = "Julio"
Case 8
MonthName = "Agosto"
Case 9
MonthName = "Septiembre"
Case 10
MonthName = "Octubre"
Case 11
MonthName = "Noviembre"
Case 12
MonthName = "Diciembre"
Case Else
MonthName = "ERROR!"
End Select
End Function

Function LastDay(MyMonth, MyYear)
' Returns the last day of the month. Takes into account leap years
' Usage: LastDay(Month, Year)
' Example: LastDay(12,2000) or LastDay(12) or Lastday


Select Case MyMonth
Case 1, 3, 5, 7, 8, 10, 12
LastDay = 31

Case 4, 6, 9, 11
LastDay = 30

Case 2
If IsDate(MyYear & "-" & MyMonth & "-" & "29") Then LastDay = 29 Else LastDay = 28

Case Else
LastDay = 0
End Select
End Function
%>