The code is below.
How can I modify this code so that when called in a popup window and a date
is clicked, that date is inserted into a form field on the original page. I
know how to pass this value back but do not know how to modify this code to
include the correct line.
**** CODE FOLLOWS****
<%
Option Explicit
dim qsDate
qsDate=request.querystring("date")
if isDate(qsDate) then
'Start the Border Table
response.write("<table cellspacing=0 border=0 cellpadding=0>" & chr(13))
response.write(" <tr>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=1></td>"
& chr(13))
response.write(" <td width=240><img src=""dot.gif"" width=240
height=1></td>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=1></td>"
& chr(13))
response.write(" </tr>" & chr(13))
response.write(" <tr>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=""100%""
</td>" & chr(13)) response.write(" <td width=240>" & chr(13))
DrawCalendarMonth (qsDate)
'Close the Border Table
response.write(" </td>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=""100%""</td>" & chr(13))
response.write(" </tr>" & chr(13))
response.write(" <tr>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=1></td>"
& chr(13))
response.write(" <td width=200><img src=""dot.gif"" width=240
height=1></td>" & chr(13))
response.write(" <td width=1><img src=""dot.gif"" width=1 height=1></td>"
& chr(13))
response.write(" </tr>" & chr(13))
response.write("</table>" & chr(13))
else
response.write("<font face=verdana, arial>" & chr(13))
if qsDate="" then
response.write("You didn't enter a date. Append "?date=",
followed by the date to the URL.<br><br>Example:
http://server/calDraw.asp?date=2/7/01<br>" & chr(13))
else
response.write("The Date you entered (" & qsDate & ") is not valid.<br>" &
chr(13))
end if
end if
Sub DrawNormalDay(DayNumber)
' Draws a day cell - date is in current month
' The response.write's are separate lines for clarity only
response.write(" <td style=""cursor:hand;"" ")
response.write("onmouseover=""this.style.backgroun dColor='white';"" ")
response.write("onmouseout=""this.style.background Color='#cccccc';"" ")
response.write("bgcolor=""#cccccc"" align=center>")
response.write("<font face=verdana, arial size=2>" & DayNumber)
window.opener.document.form2.txtDate.value = DayNumber ;
window.close
response.write("</font></td>" & chr(13))
End Sub
Sub DrawOtherDay(DayNumber)
' Draws a day cell - date is in previous or next month
' The response.write's are separate lines for clarity only
response.write(" <td bgcolor=""#eeeeee"" align=center>")
response.write("<font face=verdana, arial size=2 color=""darkgray"">")
response.write(DayNumber & "</font></td>" & chr(13))
End Sub
Sub DrawCalendarMonth(theDate)
dim thisMonthFirstDay
dim nextMonthFirstDay
dim thisMonthLastDay
dim lastMonthLastDay
dim calBeginDate
dim counter
'Set the Date variables
thisMonthFirstDay=cDate(month(theDate) & "/1/" & year(theDate))
nextMonthFirstDay=dateAdd("m",1,thisMonthFirstDay)
thisMonthLastDay=dateadd("d",-1,nextMonthFirstDay)
lastMonthLastDay=dateadd("d",-1,thisMonthFirstDay)
calBeginDate=dateadd("d",1-weekday(thisMonthFirstDay),thisMonthFirstDay)
'Start the Calendar Table
response.write(" <table width=240 bordercolor=white border=1
style=""border-collapse:collapse"">" & chr(13))
response.write(" <tr bgcolor=beige>" & chr(13))
response.write(" <td style=""cursor:hand;""
onmouseover=""this.style.backgroundColor='white';" "
onmouseout=""this.style.backgroundColor='';""
onclick=""window.location='calDraw.asp?date=" & dateadd("yyyy",-1,theDate) &
"';"" align=center><font face=verdana, arial size=2><<</font></td>" &
chr(13))
response.write(" <td style=""cursor:hand;""
onmouseover=""this.style.backgroundColor='white';" "
onmouseout=""this.style.backgroundColor='';""
onclick=""window.location='calDraw.asp?date=" & dateadd("m",-1,theDate) &
"';"" align=center><font face=verdana, arial size=2><</font></td>" &
chr(13))
response.write(" <td colspan=3 align=center><font face=verdana, arial
size=2>" & Monthname(month(theDate),true) & " '" & right(year(theDate),2) &
"</font></td>" & chr(13))
response.write(" <td style=""cursor:hand;""
onmouseover=""this.style.backgroundColor='white';" "
onmouseout=""this.style.backgroundColor='';""
onclick=""window.location='calDraw.asp?date=" & dateadd("m",1,theDate) &
"';"" align=center><font face=verdana, arial size=2>></font></td>" &
chr(13))
response.write(" <td style=""cursor:hand;""
onmouseover=""this.style.backgroundColor='white';" "
onmouseout=""this.style.backgroundColor='';""
onclick=""window.location='calDraw.asp?date=" & dateadd("yyyy",1,theDate) &
"';"" align=center><font face=verdana, arial size=2>>></font></td>" &
chr(13))
response.write(" </tr>" & chr(13))
response.write(" <tr bgcolor=""#aaaaaa"">" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Su</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Mo</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Tu</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>We</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Th</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Fr</font></td>" & chr(13))
response.write(" <td align=center><font face=verdana, arial
size=2>Sa</font></td>" & chr(13))
response.write(" </tr>" & chr(13))
'Start the First Row of Days
response.write(" <tr>" & chr(13))
' If the First day of the month is not Sunday, draw previous month's ending
days
if weekday(thisMonthFirstDay)>1 then
For counter = day(calBeginDate) to day(lastMonthLastDay)
DrawOtherDay (counter)
Next
end if
' Draw each day of the specified month. After each Saturday, end the row &
start a new one
For Counter=1 to day(thisMonthLastDay)
DrawNormalDay (counter)
if weekday(cDate(month(theDate) & "/" & counter & "/" & year(theDate))) =
7 then
response.write(" </tr>" & chr(13))
response.write(" <tr>" & chr(13))
end if
next
' If the Last day of the month is not Saturday, draw next month's beginning
days
if weekday(thisMonthLastDay)<7 then
For counter = 1 to 7-weekday(thisMonthLastDay)
DrawOtherDay (counter)
Next
end if
'End the Last Row and the Calendar
response.write(" </tr>" & chr(13))
response.write(" </table>" & chr(13))
end sub
%>