Click here to get back home

onClick="CallMultipleFns" only invokes first function

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
onClick="CallMultipleFns" only invokes first function RichardOnRails 10-08-2007
Posted by RichardOnRails on October 8, 2007, 9:48 am
Please log in for more thread options
Hi All,

I put up a toy webpage to test the use of various javascript
functions, etc.:
http://home.comcast.net/~CaptQueeg/JavaScriptDemo3.html

It has three links:

#1 clears a Trace area and adds three lines

#2 appends another line

#3 invokes functions 1 & 2 (with their respective arguments), but it
only presents the results of #1. It seems as though #2 never gets
invoked.

I tested this in both Firefox2 and IE7, as well my IDE, Aptana.

Did I make some dumb mistake, as usual :-( ?

Thanks in Advance,
Richard

P.S. I posted a version of this question on JavaScript Forum, but it
has very low traffic and waits upon moderator-review before actually
posting anything. I prefer this forum.


Posted by Chris Beall on October 8, 2007, 10:02 pm
Please log in for more thread options
RichardOnRails wrote:
> Hi All,
>
> I put up a toy webpage to test the use of various javascript
> functions, etc.:
> http://home.comcast.net/~CaptQueeg/JavaScriptDemo3.html
>
> It has three links:
>
> #1 clears a Trace area and adds three lines
>
> #2 appends another line
>
> #3 invokes functions 1 & 2 (with their respective arguments), but it
> only presents the results of #1. It seems as though #2 never gets
> invoked.
>
> I tested this in both Firefox2 and IE7, as well my IDE, Aptana.
>
> Did I make some dumb mistake, as usual :-( ?
>
> Thanks in Advance,
> Richard
>
> P.S. I posted a version of this question on JavaScript Forum, but it
> has very low traffic and waits upon moderator-review before actually
> posting anything. I prefer this forum.
>

RoR,

Line 68 is:
var iCount = arElements.length
This fails because arElements is not defined. At this point in time all
of the expected output has already appeared, so you don't notice the
failure (which prematurely terminates the script).
BUT, when you have an outer script that calls the inner one twice, the
failure of the first call also terminates the outer script and the
second call is never made.

Remove the comment delimiters from the line (2 lines up):
// var arElements = document.getElementsByTagName(sType)
and it will work.

In Firefox:
Tools
Error console

will show you any JavaScript parsing or execution errors. This is where
to start looking for this sort of thing.

Chris Beall

Posted by RichardOnRails on October 9, 2007, 3:17 am
Please log in for more thread options
Hi Chris,

Thanks for your excellent help.

> Line 68 is:
> var iCount = arElements.length
> This fails because arElements is not defined. [snip]

That was my stupid mistake: I had fooled around with this code so
much that I left trash on the bottom. I excised it all, and it ran as
expected.

> In Firefox:
> Tools
> Error console
>
> will show you any JavaScript parsing or execution errors. This is where
> to start looking for this sort of thing.

I didn't know that. Thanks for that heads-up.

I didn't think of it, because I haven't used it much, but I should
have run this with Firebug enabled. That was another stupid mistake.

Best wishes,
Richard


Similar ThreadsPosted
javascript in href or onclick? August 14, 2008, 5:26 am
target or onclick with XHTML 1.1 & Validator XHTML2 October 7, 2004, 1:41 pm
'sorry this function has been disabled' February 5, 2008, 10:09 am
Function Keys as shortcuts? February 12, 2007, 2:47 pm
invoke browser 'back' function May 18, 2005, 7:08 pm
Deactivate browser's print function July 28, 2007, 9:16 am
is it possible to submit to a specific function inside another file March 16, 2005, 4:17 am
Valid XHTML but Javascript function failing? August 8, 2005, 5:38 am
HTML Tables vs. CSS Layers - when function and form coincide January 30, 2007, 3:25 am
Need help with my site - search function within my site not working?!? April 24, 2008, 8:52 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap