473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Modifying Code

I have downloaded some sample code from the net to display a calendar etc.

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 &quot;?date=&quot;,
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>&lt;&lt;</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>&lt;</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>&gt;</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>&gt;&gt;</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
%>

Jul 19 '05 #1
0 1540

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Japcuh | last post by:
How do you write self modifying code in Java? Japcuh (Just Another Perl C Unix Hacker) http://www.catb.org/~esr/faq/hacker-howto.htm#what_is ..0. ...0 000
6
by: qwweeeit | last post by:
Hi all, when I was young I programmed in an interpreted language that allowed to modify itself. Also Python can (writing and running a module, in-line): fNew =open("newModule.py",'w') lNew=...
2
by: Yavuz Bogazci | last post by:
Hi, i am reading the LastAccessTime, LastWriteTime and DateofCreation of a file. The second and third are working well, but each time i want to read the LastAccessTime, its set to "now". How can...
13
by: Robin Becker | last post by:
When young I was warned repeatedly by more knowledgeable folk that self modifying code was dangerous. Is the following idiom dangerous or unpythonic? def func(a): global func, data data =...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
12
by: AES | last post by:
Can an HTML web page dynamically modify its own code? (without resort to Java or any other non-HTML complexities) That is, is there any provision in HTML such that a single "Next" button on a...
56
by: subramanian100in | last post by:
The standard allows that we can copy strings onto arg, arg, etc. Why is it allowed ? What can be the maximum length of such a string that is copied ?
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
6
by: Arnshea | last post by:
(apologies for the crosspost) I'm working with an MFC based COM object. From C# I'd like to be able to call a method on the COM object that takes a string array and modifies the contents. Is...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.