473,394 Members | 2,160 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,394 software developers and data experts.

calling multiple functions from a single event

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

Jul 20 '05 #1
10 12967
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
-------------------------------------------------
Jul 20 '05 #2
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
-------------------------------------------------


Jul 20 '05 #3
<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.
Jul 20 '05 #4
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
-------------------------------------------------
Jul 20 '05 #5
Lee
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.

Jul 20 '05 #6
"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.
Jul 20 '05 #7
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


Jul 20 '05 #8
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.'
Jul 20 '05 #9
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


Jul 20 '05 #10
Lee
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.

Jul 20 '05 #11

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

Similar topics

2
by: bmatt | last post by:
I am trying to support multiple interpreter instances within a single main application thread. The reason I would like separate interpreters is because objects in my system can be extended with...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
12
by: scottt | last post by:
hi, I am having a little problem passing in reference of my calling class (in my ..exe)into a DLL. Both programs are C# and what I am trying to do is pass a reference to my one class into a DLL...
2
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors,...
4
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
7
by: pronerd | last post by:
Does any one know how to add a function to an event handler with out losing the current event handler? For example you can add multiple functions to a single event handler with something like : ...
2
by: Immortal Nephi | last post by:
You may have heard diamond shape. You create one base class. One base class has member functions and member variables. You create two derived classes. All member functions and member variables...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.