Solved

Calling two or more functions at same time

Posted on 2008-06-22
3
1,902 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery won't work on my html page 4 290
how to avoid duplicate value selection in drop down 18 1,453
form submit not working 9 157
Sorting tables using javascript 9 79
Adding Computers to AD groups through an SCCM Task Sequence
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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