Solved

Calling two or more functions at same time

Posted on 2008-06-22
3
1,899 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
Comment Utility
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
Comment Utility
return (function1 && function2); worked just fine. Thanks!
0
 
LVL 41

Expert Comment

by:HonorGod
Comment Utility
Excellent.  Glad to hear it.

Thanks for the grade & points.

Good luck & have a great day.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
A procedure for exporting installed hotfix details of remote computers using powershell
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now