Title: Testing multiple functions by another function
Last modified: January 25, 2017

---

# Testing multiple functions by another function

 *  Resolved [hsntgm](https://wordpress.org/support/users/hsntgm/)
 * (@hsntgm)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/testing-multiple-functions-by-another-function/)
 * Hello codepeople !
 * I have multiple functions and i forced them to give me their results.Now i will
   compare these function’s returns by another function.My code structer will tell
   my problem better then me.
 * Unfortunately this structure doesn’t work.
    Thanks in advance.
 *     ```
       <script>
       jQuery(document).on(
       'click',
       '[id*="fieldname'+'X_"]', function() MyFunction {
       	var success = false;
   
       	if (condition) {
       		do something;
                       success = true;
   
       	} else {
       		do something;
       		success = false;
       	}
       	return success;
       });
       </script>
       ```
   
 *     ```
       <script>
       jQuery(document).on(
       'click',
       '[id*="fieldname'+'X_"]', function() MySecondFunction {
       	var success = false;
   
       	if (condition) {
       		do something;
       	        success = true;
   
       	} else {
       		do something;
       		success = false;
       	}
       	return success;
       });
       </script>
       ```
   
 *     ```
       <script>
       jQuery(document).on(
       'click',
       '[id*="fieldname'+'X_"]', function() testMyFunctionsAndTakeAction {
   
       	if (MyFunction() == true && MySecondFunction() == false ) {
       		do something;
       	} 
       });
       </script>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/testing-multiple-functions-by-another-function/#post-8696319)
 * Hello,
 * There some basic javascript errors, I recommend you the use of a tutorial.
 * In javascript if you are defining the functions directly into the event they 
   are lambda functions and do not include a name (furthermore replace the X by 
   the real number in the field’s name, and the pseudo code):
 *     ```
       jQuery(document).on(
       'click',
       '[id*="fieldname'+'X_"]', function(){
       	var success = false;
   
       	if (condition) {
       		do something;
                       success = true;
   
       	} else {
       		do something;
       		success = false;
       	}
       	return success;
       });
       ```
   
 * If you want to use the function in the event, and call it from another function,
   the correct is create the function, and then use it in the event:
 *     ```
       function MyFunction(){
       	var success = false;
   
       	if (condition) {
       		do something;
                       success = true;
   
       	} else {
       		do something;
       		success = false;
       	}
       	return success;
       }
   
       jQuery(document).on(
       'click',
       '[id*="fieldname'+'X_"]', 
       MyFunction
       );
       ```
   
 * Best regards.
 *  Thread Starter [hsntgm](https://wordpress.org/support/users/hsntgm/)
 * (@hsntgm)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/testing-multiple-functions-by-another-function/#post-8697142)
 * Hello,
 * Thank you for your patience, i understand lambda functions from tutorials.
 * Sometimes my brain looking for more complicated solution.Then i will realise 
   and find the correct path.I managed to solve this issue with simple `else if`.
 * I had to separate the button notifications because of the terms and conditions
   tickbox unchecked or there are the missing informations.
 * So far, so good ! Now all client side validations working like a charm with your
   support.
 * Sincerely,
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/testing-multiple-functions-by-another-function/#post-8697507)
 * Perfect.
 * Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Testing multiple functions by another function’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/testing-multiple-functions-by-another-function/#post-8697507)
 * Status: resolved