Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author codepeople

    (@codepeople)

    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

    (@dailypriceaction)

    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

    (@codepeople)

    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

    (@dailypriceaction)

    Got it. Thanks!

    Thread Starter dailypriceaction

    (@dailypriceaction)

    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

    (@codepeople)

    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

    (@dailypriceaction)

    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

    (@codepeople)

    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

    Best regards.

    Thread Starter dailypriceaction

    (@dailypriceaction)

    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

    (@codepeople)

    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.