Solved

Calling two or more functions at same time

Posted on 2008-06-22
3
1,903 Views
Last Modified: 2009-12-16
Hi
I am trying to call different javascript functions using onSubmit event.
My problem is that only one function (first one) works at same time (see attached code). The second function is simply ignored. If I cancell first funtion, the second one works perfectly.

Can you tell me how to call two o more functions at same time, using same event?

Thanks


<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form_Utente" onsubmit="return Controlla_Data(data_nascita.value,'Data di nascita'); return Controlla_Mail(email.value);">

Open in new window

0
Comment
Question by:minjakon
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 125 total points
ID: 21840767
Well, Javascript is not designed to be multi-threaded.
Normally, there is only one thread of control.  So, the
statements that you have, i.e.,

return Controlla_Data(data_nascita.value,'Data di nascita');
return Controlla_Mail(email.value);

can not allow the second function to be called.  What
happens is that the first routine (i.e., Controlla_Data()) is
called, and the result that is returned is used as a return
value during the submit processing.

You probably want something like:

return Controlla_Data(data_nascita.value,'Data di nascita') ||  Controlla_Mail(email.value);

This construct, i.e.,

function#1() || function#2()

will invoke both.  However, it expects the returned values to
be boolean.  If they aren't we have to do something else...
0
 

Author Comment

by:minjakon
ID: 21840840
return (function1 && function2); worked just fine. Thanks!
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21841003
Excellent.  Glad to hear it.

Thanks for the grade & points.

Good luck & have a great day.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question