Title: Conditional Fields Formula Not Working
Last modified: August 22, 2016

---

# Conditional Fields Formula Not Working

 *  Resolved [jamiewalden](https://wordpress.org/support/users/jamiewalden/)
 * (@jamiewalden)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/conditional-fields-formula-not-working/)
 * I’m having trouble with the conditional fields.
 * I’m trying to set a formula where if they select from a dropdown menu, each option
   in the dropdown results in a different calculation.
 * The formula I’m trying to use is this:
 *     ```
       (function(){
   
       if(fieldname3==1){
       return (fieldname5*10);
   
       if(fieldname3==2){
       return (fieldname5*100);
   
       }
       })()
       ```
   
 * The fieldname3 is the first field which is the dropdown, then fieldname5 is the
   second field the user fills out. But it’s not working.
 * AND
 * When I select from the dropdown, that field completely disappears. Could you 
   please help? Thanks very much.
 * See calculator here:
    [http://www.americandatanetwork.com/test-3/](http://www.americandatanetwork.com/test-3/)
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

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

 *  Thread Starter [jamiewalden](https://wordpress.org/support/users/jamiewalden/)
 * (@jamiewalden)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/conditional-fields-formula-not-working/#post-5501127)
 * Got this working with this:
 *     ```
       (function(){
       var v = fieldname3;
       if(v==1) return fieldname2*10;
       if(v==2) return fieldname2*100;
       })()
       ```
   
 * Not sure why the dropdown was disappearing tho.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/conditional-fields-formula-not-working/#post-5501434)
 * Hi,
 * The issue in your first equation was related with the “}” symbols. You’ve used
   the equation:
 * (function(){
    if(fieldname3==1){ return (fieldname5*10);
 * if(fieldname3==2){
    return (fieldname5*100); } })()
 * but the correct is:
 * (function(){
    if(fieldname3==1){ return (fieldname5*10); } if(fieldname3==2){
   return (fieldname5*100); } })()
 * Pay attention to the “}” symbol for closing the first conditional statement.
 * Best regards.

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

The topic ‘Conditional Fields Formula Not Working’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/conditional-fields-formula-not-working/#post-5501434)
 * Status: resolved