Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling two or more functions at same time

Posted on 2008-06-22
3
Medium Priority
?
1,912 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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

926 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