Title: Multiple condition for different equation
Last modified: July 18, 2024

---

# Multiple condition for different equation

 *  Resolved [ramanandmehta](https://wordpress.org/support/users/ramanandmehta/)
 * (@ramanandmehta)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-condition-for-different-equation/)
 * Hi sir, Im creating a simple bmr calculator in which I have two radio button 
   fields for equation and gender selections.
   I am using this code in formula but
   its not working.
 *     ```wp-block-code
       (function(){    if (fieldname56 === "Miffin St Jeor") {        if (fieldname3 === "Male") {            return (9.99 * fieldname30) + (6.25 * fieldname31) - (4.92 * fieldname2) + 5;        } else if (fieldname3 === "Female") {            return (9.99 * fieldname30) + (6.25 * fieldname31) - (4.92 * fieldname2) - 161;        }    } else if (fieldname56 === "Harris Benedict Equation (Revised)") {        if (fieldname3 === "Male") {            return 88.362 + (13.397 * fieldname30) + (4.799 * fieldname31) - (5.677 * fieldname2);        } else if (fieldname3 === "Female") {            return 447.593 + (9.247 * fieldname30) + (3.098 * fieldname31) - (4.33 * fieldname2);        }    }    return 0; // Return 0 if the conditions are not met})();
       ```
   
 * Please guide me, thanks.

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-condition-for-different-equation/#post-17897975)
 * Hello [@ramanandmehta](https://wordpress.org/support/users/ramanandmehta/)
 * Please don’t use single line comments in the equations:
 *     ```wp-block-code
       // Return 0 if the conditions are not met
       ```
   
 * The plugin tries to minify the equations code and the single-line comments structure
   could make this process fail. Use block comment structure instead:
 *     ```wp-block-code
       /* Return 0 if the conditions are not met */
       ```
   
 * The rest of the code in the equation seems correct, but I would need the link
   to the page containing the form because I cannot check from the code in your 
   entry if the fields’ values used for comparing are correct.
 * Best regards.
 *  Thread Starter [ramanandmehta](https://wordpress.org/support/users/ramanandmehta/)
 * (@ramanandmehta)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-condition-for-different-equation/#post-17897994)
 * Salute for the faster response; I have never seen before.
   I have removed the 
   comment but it’s not working. here is [test page](https://tdee-calculator.net/test/)
    -  This reply was modified 1 year, 10 months ago by [ramanandmehta](https://wordpress.org/support/users/ramanandmehta/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-condition-for-different-equation/#post-17898043)
 * Hello [@ramanandmehta](https://wordpress.org/support/users/ramanandmehta/)
 * Thank you very much for the link. The issue is caused by your form structure 
   and fields’ values. For example, in the gender field, you entered the choices’
   texts but not their values. So, the value of the gender field will be the empty
   text. The equations use the choices’ values, please enter them.
 * The “Formula” field has an additional problem, you left its choices’ values empty
   and configured it as dependent on the “Show Advance setting” field. So, when 
   the “Show Advance setting” is unticked, the “Formula” field value will be empty.
 * So, the solution to your equation is:
    1. Enter all choices values, in the “Gender” and “Formula” fields.
    2. If you have configured the “Formula” field as dependent, you should implement
       the condition in the equation as follows:
 *     ```wp-block-code
       if (fieldname56 === "Miffin St Jeor") {/* Your code Here */} else {/* Your code Here */}
       ```
   
 * In this case, the “else” code block would be evaluated if the fieldname56 choice
   selected is `"Revised Harris-Benedict"` or the field is deactivated by the dependency.
 * Best regards.

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

The topic ‘Multiple condition for different equation’ 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: [1 year, 10 months ago](https://wordpress.org/support/topic/multiple-condition-for-different-equation/#post-17898043)
 * Status: resolved