Title: Interdependent drop down values
Last modified: August 22, 2016

---

# Interdependent drop down values

 *  Resolved [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/)
 * I’m wondering if it’s possible to have interdependent drop down values. In other
   words, a field that is shown/hidden based on the selection from two separate 
   drop downs. I need to be able to show/hide “xyz” field based on the selection
   from drop down “a” but also change “xyz” field to show “abc” field instead if
   drop down “b” has a specific value.
 * The best example of this is the following calculator:
 * [http://www.earnforex.com/position-size-calculator](http://www.earnforex.com/position-size-calculator)
 * Notice how the last field is dependent upon the selection from both drop down
   menus.
 * Here is my page for reference:
 * [http://dailypriceaction.com/forex-position-size-calculator](http://dailypriceaction.com/forex-position-size-calculator)
 * Thanks in advance!
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685517)
 * Hi,
 * To get that a field be dependent of multiple fields, you should show/hide the
   field from an equation.
 * For example, in this explanation the if the value of fieldname1 is equal to 10,
   and the value of the fieldname2 is equal to 100, the form should display the 
   fieldname3 field, or hide it in other cases. First, you should assign a class
   name to the fieldname3 to identify the field from the equations(for example enter
   the value: myclass through the attribute: “Add Css Layout Keywords” of the fieldname3
   field). Finally, you should use the following snippet of code as part of your
   equation:
 * if(fieldname1 == 10 && fieldname2 == 100 ) jQuery(‘.myclass’).show();
    else jQuery(‘.
   myclass’).hide();
 * The fields names and values have been selected randomly, only for the explanation,
   use the fields names, and values, corresponding to your project.
 * Best regards.
 *  Thread Starter [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685532)
 * Thanks for the quick response. Does this also work for drop down values rather
   than values entered as text? It doesn’t seem to be working for me. So in my example
   drop down values of USD, EUR, etc.
 * In your example, the snippet of code should be placed in the equation box for
   fieldname3?
 * Thanks.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685539)
 * Hi,
 * Your current equation is:
 * if(fieldname3 == USD && fieldname7 == USD/JPY ) jQuery(‘.usdjpy’).show();
    else
   jQuery(‘.usdjpy’).hide();
 * First, you should use the previous code as part of a equation with the function
   format. Second, the text should be enclosed with quotes, similar to:
 * (function(){
    if(fieldname3 == ‘USD’ && fieldname7 == ‘USD/JPY’ ) jQuery(‘.usdjpy’).
   show(); else jQuery(‘.usdjpy’).hide(); })()
 * Best regards.
 *  Thread Starter [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685549)
 * Got it. Thanks!
 *  Thread Starter [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685552)
 * One more thing. I only want the final numbers of the calculation to use the fields
   that are being shown at the time. As it is it’s trying to use the values from
   the hidden fields (of which there are none) when running the equation.
 * I’m not sure how to set the equation to only use the values from the fields that
   are shown.
 * Thanks again for all your help.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685554)
 * Hi,
 * In this case you should assign the class name “ignore” to the field, to prevent
   the field be used in the equation. Modify your equation like follow:
 * (function(){
    if(fieldname3 == ‘USD’ && fieldname7 == ‘USD/JPY’ ) jQuery(‘.usdjpy’).
   show().find( ‘.field’ ).removeClass( ‘ignore’ ); else jQuery(‘.usdjpy’).hide().
   find( ‘.field’ ).addClass( ‘ignore’ ); })()
 * Best regards.
 *  Thread Starter [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685567)
 * I added “ignore” as a class and entered the equation you provided. However the
   equation seems to still be using the hidden field.
 * I also get a black box around the field when using “ignore” as a class name…
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685587)
 * Hi,
 * You’ve assigned the class “ignore” to the field, through the attribute: “Add 
   Css Layout Keywords”, please remove the class name from this attribute, because
   it is the cause of black frame. The “ignore” class is assigned directly to the
   input field, from the equation.
 * Please test the following equation:
 * (function(){
 * if(fieldname3 == ‘USD’ && fieldname7 == ‘USD/JPY’ ) jQuery(‘.usdjpy’).show().
   children( ‘.field’ ).removeClass( ‘ignore’ );
    else jQuery(‘.usdjpy’).hide().
   children( ‘.field’ ).addClass( ‘ignore’ );
 * })()
 * If you need additional assistance with your equations, I offer you a custom coding
   service. Please, contact us through our support page:
 * [http://wordpress.dwbooster.com/support](http://wordpress.dwbooster.com/support)
 * Best regards.
 *  Thread Starter [dailypriceaction](https://wordpress.org/support/users/dailypriceaction/)
 * (@dailypriceaction)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685746)
 * That latest bit of code still doesn’t work. The calculation is still taking the
   hidden fields into account.
 * I wouldn’t consider this a request that requires me to pay for “custom coding”.
   Ignoring hidden fields from a calculation isn’t something out of the ordinary.
 * You also seem to have changed part of the code in your last response, changing“.
   field” to “.children”. However I don’t see where you mentioned anything about
   this in your post.
 * Any help to get this up and running is appreciated.
 * Thanks in advance.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685747)
 * Hi,
 * Ok, I will give you a more simple way to solve you problem. Insert in your form
   a calculated field, enter the following equation:
 * IF(AND(fieldname3 == ‘USD’, fieldname7 == ‘USD/JPY’), 1, 0)
 * and then in the dependencies section of the calculated field, select the rule:
   If value is equal to, enter the number 1 in the input box, and select the field
   to be displayed with this conditions.
 * Best regards.

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

The topic ‘Interdependent drop down values’ 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/)

 * 10 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/interdependent-drop-down-values/#post-5685747)
 * Status: resolved