473,383 Members | 1,805 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,383 software developers and data experts.

This function has an onClick event that calls a function that calls This function

Bob
The title says it all. The nextmon() and prevmon() functions are listed
afterward, since they call fDrawCal().I'm sure you see the
problem...prevmon() is not defined prior to being mentioned in the
onClick event. But what's the solution? Here's the structure that I
have now:

function fDrawCal(iMonth, iYear) {
var myMonth;
myMonth = fBuildCal(iYear, iMonth);
document.write('<table id="calendar" cellspacing="0" cellpadding="0"
summary="One month calendar">');
document.write('<caption><a onClick="prevmon()" title="previous month"
class="nav">&laquo;&nbsp;</a>'+ThisMonth+' '+iYear+'<a onClick"nextmon"
title="next month" class="nav">&nbsp;&raquo;</a></caption>');
document.write(' <tr>');
...
etc.
...
}

function nextmon() {
iMonth = iMonth+1;
if (iMonth==13) {iYear=iYear+1; iMonth=1}
fDrawCal(iMonth, iYear);
}

function prevmon() {
iMonth = iMonth-1;
if (iMonth==0) {iYear=iYear-1; iMonth=12}
fDrawCal(iMonth, iYear);
}

Oct 24 '06 #1
5 2827

Bob wrote:
The title says it all.
No it doesn't.
The nextmon() and prevmon() functions are listed
afterward, since they call fDrawCal().I'm sure you see the
problem...prevmon() is not defined prior to being mentioned in the
onClick event.
That isn't the problem (at least for what you have posted). Your call
to document.write will completely erase the content of the document,
the script that is in the page no longer exists when the new page is
written.

But what's the solution?
Do not use document.write() to build your calendar, use a in-page popup
(like thousands of calendar pop-ups already do).

Matt Kruse has a bunch of them here:

<URL: http://www.mattkruse.com/javascript/calendarpopup/ >
--
Rob

Oct 24 '06 #2
Bob
Do not use document.write() to build your calendar, use a in-page popup
(like thousands of calendar pop-ups already do).

Matt Kruse has a bunch of them here:

<URL: http://www.mattkruse.com/javascript/calendarpopup/ >
I'm not trying to select a date. CSS controls the position of the
calendar. I was hoping to have the onClick event create another
calendar...on top of the initial calendar, on the page - not as a pop
up.

In Pascal/Delphi there is a Forward declaration that handles this type
of organization.

var Imon = 1;
function Foo; forward;

function Bar(Imon) {
if (Imon <12) {Foo();}
}

function Foo() {
Imon = Imon+1;
Bar(Imon)
}

This is somewhat like recursion.

I was hoping that there is some way in JavaScript to code something
like this structure.

Oct 24 '06 #3

Bob wrote:
Do not use document.write() to build your calendar, use a in-page popup
(like thousands of calendar pop-ups already do).

Matt Kruse has a bunch of them here:

<URL: http://www.mattkruse.com/javascript/calendarpopup/ >

I'm not trying to select a date. CSS controls the position of the
calendar. I was hoping to have the onClick event create another
calendar...on top of the initial calendar, on the page - not as a pop
up.
Then just put it in the page inside a div or whatever. Your
fundamental problem is using document.write() after the page has
finished loading - it completely replaces the current content of the
page.

In Pascal/Delphi there is a Forward declaration that handles this type
of organization.
It has been over 15 years since I had anything to do with Pascal and
have never used any version of Delphi. There is no point in explaining
javascript in terms of code from some other language unless you know
that I know that language.

[...]
This is somewhat like recursion.
I can't see how it has any relevance to the problem at hand.

One of Matt's functions writes a calendar into a div element (the one
labelled "Default calendar using the DIV-style display"). He uses it as
a pop-up, to convert it to a stock page element, change the style stuff
in regard to position and display attributes and there you have it.
--
Rob

Oct 24 '06 #4

Bob wrote:
Do not use document.write() to build your calendar, use a in-page popup
(like thousands of calendar pop-ups already do).

Matt Kruse has a bunch of them here:

<URL: http://www.mattkruse.com/javascript/calendarpopup/ >

I'm not trying to select a date. CSS controls the position of the
calendar. I was hoping to have the onClick event create another
calendar...on top of the initial calendar, on the page - not as a pop
up.

In Pascal/Delphi there is a Forward declaration that handles this type
of organization.

var Imon = 1;
function Foo; forward;

function Bar(Imon) {
if (Imon <12) {Foo();}
}

function Foo() {
Imon = Imon+1;
Bar(Imon)
}

I was hoping that there is some way in JavaScript to code something
like this structure.
You are misunderstanding the problem - it is not that your code is
refering to a function that has not yet been defined (javascript
couldn't care less), it is that document.write replaces the content of
the current document with the string you send it. Trying to apply
language concepts from Pascal to Javascript is only going to hurt you,
as it is here.

You are wiping out your code completely when you use document.write, so
the function your onclick handler calls nolonger exists. This is what
the previous poster was trying to explain to you.

The solution is not to use document.write (and thus create a new
document) as was already pointed out, but to replace the calendar
within the current document. RobG has already given you pointers on how
to do this.

Oct 24 '06 #5
Bob
You are misunderstanding the problem - it is not that your code is
refering to a function that has not yet been defined (javascript
couldn't care less), it is that document.write replaces the content of
the current document with the string you send it. Trying to apply
language concepts from Pascal to Javascript is only going to hurt you,
as it is here.
Thanks Rob and N.. I now understand the real problem - the most
important part to solving any problem.

Oct 24 '06 #6

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

Similar topics

3
by: Brett | last post by:
What is the following code doing? I see evt and event but what is the difference? <input type="radio" id="us_countryFlag1" name="us_country" onclick="togglePurDec(event)">Yes <script>...
4
by: Iver Erling Årva | last post by:
I have an application that uses a window.open() to open it's own main window where all my programs takes place. I use a timeout so if nothing goes on for 15 minutes the document below is called. To...
1
by: lawrence | last post by:
I'm trying to gain a better understanding of javascript by studying examples. I noticed this in an online tutorial. I don't get the use of "this". >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You might want...
4
by: a-ok | last post by:
function confirmDelete(id, title) { confirmation=confirm('Delete " '+title+' "?'); if (confirmation) { window.location='delete.php'; // NOTHING HAPPENS } } Tried it with...
7
by: Shapper | last post by:
Hello, I have an ASP:ImageButton where I want to call a function and pass a string: OnClick="Change_Photo("John")" I am having problems with "". I tried
5
by: Michel | last post by:
Hi Group of helpers, Following snippet of code: <HTML> <HEAD> <script> function color(value) { alert(value);
3
by: ppcguy | last post by:
i've got this for IE: node.onchange = foo; but really i'd like to pass node object to foo function also. in html i would do onchange="foo(this)"...but this has to be done in javascript at...
1
by: Ron | last post by:
Hi, I'm using javascript to dynamically generate a table (ajax/xml). What I want to achieve is when a table cell is clicked it needs to call a function and pass the event as a parameter (In IE I...
7
Haitashi
by: Haitashi | last post by:
I have a form that calls a function using the onClick event in the submit button. I would like this function to return false if the username is taken. The the original function, which I've tested,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.