Hi All,
I am trying to call 2 functions from the 1 onMouseOver event on an
anchor tag, but I can't seem to get it to work. the following should
demonstrate
<a onMouseOver="ShowMenu('Menu3');AddMenuToHoldArray( 'Menu3')">Menu
3</a>
I have tried a number of variations, like adding "javascript:" in
front of the first call, and returning True of False from the first
function, but Icant get the second function to fire after the first
one has.
by using alerts, and wathcing what IS occuring, I know that the first
is being called, but the second isn't.
I did this once some years back, but I can't seem to rember how I did,
it, and none of the example that I have located have helped, so can
anyone point me in the right direction?
thanks 10 12822
In article <a8******************************@news.teranews.co m>, re************@hotmail.com enlightened us with... I did this once some years back, but I can't seem to rember how I did, it, and none of the example that I have located have helped, so can anyone point me in the right direction?
I don't see anything wrong with the way you're calling the functions,
but if there is any error in AddMenuToHoldArray, the function won't do
anything. Did you try just putting that one in the mouseover by itself
to see if it works?
Also, javascript is case-sensitive - is the case correct in that name?
You can also try using Netscape 7 - they have a better debugger. Bring
up your page in NN, then type "javascript :" in the location bar after
you try the code and the function doesn't get called. If there was an
error, it will show up in the console.
Other than that, I'd need to see code.
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
I know that the second function is ok, an that it is never even being
entered. To test that it was being entered I placed an alert() at the
start of it, and it runs when the sedond function is the only function
on the event, but not if there are 2 functions.
I assume the problem lies somewhere in the fact that due to return
values or some such, the second function is being ignored completely
On Tue, 28 Oct 2003 07:20:00 -0600, kaeli
<in********************@NOSPAMatt.net> wrote: In article <a8******************************@news.teranews.co m>, re************@hotmail.com enlightened us with... I did this once some years back, but I can't seem to rember how I did, it, and none of the example that I have located have helped, so can anyone point me in the right direction?
I don't see anything wrong with the way you're calling the functions, but if there is any error in AddMenuToHoldArray, the function won't do anything. Did you try just putting that one in the mouseover by itself to see if it works?
Also, javascript is case-sensitive - is the case correct in that name?
You can also try using Netscape 7 - they have a better debugger. Bring up your page in NN, then type "javascript:" in the location bar after you try the code and the function doesn't get called. If there was an error, it will show up in the console.
Other than that, I'd need to see code.
------------------------------------------------- ~kaeli~ Jesus saves, Allah protects, and Cthulhu thinks you'd make a nice sandwich. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace -------------------------------------------------
<re************@hotmail.com> wrote in message
news:c8******************************@news.teranew s.com...
<snip> I assume the problem lies somewhere in the fact that due to return values or some such, the second function is being ignored completely
The attribute code that you posted is syntactically correct and should
result in both functions being called. The return value of the first
function will have no influence on the execution of the second function
as it is just being discarded by the event handling code. But the fact
that you think it may have an influence demonstrates that you are not
qualified to judge the advice that you have been given. So, to re-state
Kaeli's advice:-
1. Check that the case (and maybe spelling) of the function
calls corresponds exactly with the identifiers in the
function definitions.
2. Determine if any error messages (and, if so, which) are
being generated.
3. Post the code of the functions that are being called.
Richard.
In article <c8******************************@news.teranews.co m>, re************@hotmail.com enlightened us with... I know that the second function is ok, an that it is never even being entered.
If it isn't being entered, how can you know it's okay? :)
Call it by itself. Does it work? If you didn't test it alone to be sure
it works, it is more than likely NOT okay. I assume the problem lies somewhere in the fact that due to return values or some such, the second function is being ignored completely
Never ASSume. *g*
The return value of the first is irrelevant to the second.
Post some code or a link.
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
------------------------------------------------- re************@hotmail.com said: I know that the second function is ok, an that it is never even being entered. To test that it was being entered I placed an alert() at the start of it, and it runs when the sedond function is the only function on the event, but not if there are 2 functions.
I assume the problem lies somewhere in the fact that due to return values or some such, the second function is being ignored completely
You may not be as wrong as the other two posters seem to think,
if "some such" includes the possibility of an error exit from your
first function. Follow kaeli's advice to view the error messages
thrown from ShowMenu(), which would prevent your second function
from being invoked.
"Lee" <RE**************@cox.net> wrote in message
news:bn*********@drn.newsguy.com...
<snip> You may not be as wrong as the other two posters seem to think, if "some such" includes the possibility of an error exit from your first function. ...
Speculation on the reasons the second function does not get called may
include the first function directly calling the submit method of the
form, resulting in the current page being unloaded before the second
function gets a chance to execute and a similar effect resulting form
assigning a URL to the location object. Without being able to see the
code, speculation is just that, and ultimately Kaeli's original proposed
strategy will expose the real problem.
Richard.
OK, thanks for the info so far guys, looking at the javascript console
I noticed that there was an exception in the first routine, where I
was going 1 spot too far through an array in a loop.
Now that I have fixed that, the second function is being called. Cool
Having established what the problem was an fixed it, I have another
question.
When getting the length of abd array, should I be using the .length
property, or a the arrayLength property?
they both seem to work, or at least I'm not getting exceptions :)
ie
for (i=0;i<=menus.length-1;i++) {
HideMenu(menus[i]);
}
or
for (i=0;i<=menus.arrayLength-1;i++) {
HideMenu(menus[i]);
}
On Tue, 28 Oct 2003 11:54:49 GMT, re************@hotmail.com wrote: Hi All,
I am trying to call 2 functions from the 1 onMouseOver event on an anchor tag, but I can't seem to get it to work. the following should demonstrate
<a onMouseOver="ShowMenu('Menu3');AddMenuToHoldArray( 'Menu3')">Menu 3</a>
I have tried a number of variations, like adding "javascript:" in front of the first call, and returning True of False from the first function, but Icant get the second function to fire after the first one has.
by using alerts, and wathcing what IS occuring, I know that the first is being called, but the second isn't.
I did this once some years back, but I can't seem to rember how I did, it, and none of the example that I have located have helped, so can anyone point me in the right direction?
thanks re************@hotmail.com writes: When getting the length of abd array, should I be using the .length property, or a the arrayLength property?
There is no arrayLength property in any version of Javascript that
I know of.
they both seem to work, or at least I'm not getting exceptions :)
Sure, the last one counts while (i <= undefined), which is always
false. No action, no chance of exceptions :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
On 29 Oct 2003 12:49:04 +0100, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote: re************@hotmail.com writes:
When getting the length of abd array, should I be using the .length property, or a the arrayLength property? There is no arrayLength property in any version of Javascript that I know of.
they both seem to work, or at least I'm not getting exceptions :)
Sure, the last one counts while (i <= undefined), which is always false. No action, no chance of exceptions :)
well, that answers that one, thanks a lot.
Now off to see what else I have managed to foget over the last couple
of years :) /L
Richard Cornford said: "Lee" <RE**************@cox.net> wrote in message news:bn*********@drn.newsguy.com... <snip>You may not be as wrong as the other two posters seem to think, if "some such" includes the possibility of an error exit from your first function. ...
Speculation on the reasons the second function does not get called may include the first function directly calling the submit method of the form, resulting in the current page being unloaded before the second function gets a chance to execute and a similar effect resulting form assigning a URL to the location object. Without being able to see the code, speculation is just that, and ultimately Kaeli's original proposed strategy will expose the real problem.
I was simply pointing out that he was correct to assume that
something in the way that the first function returns may be
causing the problem. It is highly likely to be an error in
the first function. That's not just a random guess. It's
been a very common cause of such error reports in the past.
It is very unlikely that he submits the form from a function
called ShowMenu(), and doesn't report other symptoms. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
2 posts
views
Thread by bmatt |
last post: by
|
19 posts
views
Thread by Ross A. Finlayson |
last post: by
|
12 posts
views
Thread by Ron |
last post: by
|
12 posts
views
Thread by scottt |
last post: by
|
2 posts
views
Thread by Daniel Lidström |
last post: by
|
4 posts
views
Thread by Edwin Gomez |
last post: by
|
6 posts
views
Thread by Joseph Geretz |
last post: by
| |
2 posts
views
Thread by Immortal Nephi |
last post: by
| | | | | | | | | | |