Title: Multiple IF function with DropDown forms
Last modified: November 20, 2019

---

# Multiple IF function with DropDown forms

 *  Resolved [jankiel7](https://wordpress.org/support/users/jankiel7/)
 * (@jankiel7)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/)
 * I would like to make a price check calculator, that will be calculate price depends
   on what option you choose, and with and DropDown there was no problem for me 
   but with two I dont know how to make it this is my code idea:
 *     ```
       (function cena(){
   
       if(fieldname9 == "Tak") AND (fieldname11 == "Tak") return PREC((fieldname6*57)*1.1, 2);
   
       if(fieldname9 == "Tak") AND (fieldname11 == "NIE") return PREC((fieldname6*45)*1.1, 2);
   
       if(fieldname9 == "NIE") AND (fieldname11 == "Tak") return PREC((fieldname6*57), 2);
   
       else return PREC((fieldname6*45), 2);
   
       }
   
       )();
       ```
   
 * It works like you pick Height and Weight then it calculate to m2 and then it 
   depend what you choose Yes/No in to DropDowns it changes the price, but i have
   no idea how to make it work, beacuse it have to make choose from all possibility
   of choose YES/YES Yes/NO NO/YES and No/No

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12156455)
 * Hello [@jankiel7](https://wordpress.org/support/users/jankiel7/)
 * First, in javascript the logical operator that represents the AND is the double
   symbol `&&`
 * Second, in javascript the group of conditions into the `if` conditional statement
   must be enclose into parenthesis.
 * Third, the function’s name is unnecessary in the equation.
 * So, the equation would be similar to:
 *     ```
       (function(){
   
           if(fieldname9 == "Tak" && fieldname11 == "Tak") 
               return PREC(fieldname6*57*1.1, 2);
   
           if(fieldname9 == "Tak" && fieldname11 == "NIE") 
               return PREC(fieldname6*45*1.1, 2);
   
            if(fieldname9 == "NIE" && fieldname11 == "Tak") 
               return PREC(fieldname6*57, 2);
   
           return PREC(fieldname6*45, 2);
       }
   
       )();
       ```
   
 * Note that I’ve removed some unnecessary parenthesis and instructions.
 * Best regards.
 *  Thread Starter [jankiel7](https://wordpress.org/support/users/jankiel7/)
 * (@jankiel7)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12156500)
 * Thank you for the answer, i tried your code and it calculted only first IF when
   two option YES/YES are choosen, others option doesnt work
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12156516)
 * Hello [@jankiel7](https://wordpress.org/support/users/jankiel7/)
 * Please, indicate the link to the page where the form is inserted. I simply have
   modified your initial equation, trusting that the data are correct.
 * Best regards.
 *  Thread Starter [jankiel7](https://wordpress.org/support/users/jankiel7/)
 * (@jankiel7)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12156605)
 * [https://tureklamy.pl/testtesttestowy/](https://tureklamy.pl/testtesttestowy/)
 * Here is the link for the calculator, greetings.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12156647)
 * Hello [@jankiel7](https://wordpress.org/support/users/jankiel7/)
 * The issue is simple. Javascript is a case sensitive language. In the equation
   you are comparing with NIE, but the field value is Nie, and for javascript this
   comparison: `"Nie" == "NIE"` returns false. So, you should edit the fields values
   or the equation.
 * Best regards.
 *  [habib0030](https://wordpress.org/support/users/habib0030/)
 * (@habib0030)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12189425)
 * I want to return calculated value from fielname2. Pls correct below code.
 * (function(){
    if(fieldname1 = ‘hb’) return calculated value from fieldname2; })();
 * Any suggestions would be greatly appreciated.
 * Habib
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12189450)
 * Hello [@habib0030](https://wordpress.org/support/users/habib0030/)
 * In javascript the operator for equality is the double symbol: `==` because the
   symbol: `=` is used for assignment. So, the equation would be:
 *     ```
       (function(){
       if(fieldname1 == 'hb') return fieldname2;
       })();
       ```
   
 * or simply:
 *     ```
       IF(fieldname1=='hb', fieldname2, '')
       ```
   
 * Best regards.

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

The topic ‘Multiple IF function with DropDown forms’ 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/)

 * 7 replies
 * 3 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/multiple-if-function-with-dropdown-forms/#post-12189450)
 * Status: resolved