Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calling two or more functions at same time

Posted on 2008-06-22
3
Medium Priority
?
1,908 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

718 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