• Resolved Alwin

    (@wp-opti)


    I am using a Calculated field with this Equation:

    IF(AND(100>=fieldname2,200>=fieldname6,200>=fieldname41,100>=fieldname42,100>=fieldname43,100>=fieldname44),
    PREC(MAX(3.9,fieldname40*0.60+2.70),2), ‘Maximale maat Polystyreen is 100×200 cm’)

    Now I like to add one more rule:

    When the warning text (Maximale maat Polystyreen is 100×200 cm) is displayed in the Calculated field (so instead of the calculated number) then I would like to hidde fieldname16.

    In other words: when the Calculated field is not showing the calculated number (because of one of the conditional statements into the equation) I would like to hide fieldname16.

    Is that possible?

    Thank you for your help!

    Regards,
    Alwin

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

    (@codepeople)

    Hello @wp-opti,

    In your case, where you are not sure about the result, the dependencies might not be a solution, and you need show/hide the field with code, as follows:

    
    (function(){
      
      if(AND(fieldname2<=100,fieldname6<=200,fieldname41<=200,fieldname42<=100,fieldname43<=100,fieldname44<=100))
        {
            jQuery('[id*="fieldname'+'16_"]').closest('.fields').show();
            return PREC(MAX(3.9,fieldname40*0.60+2.70),2);
        }
        else
        {
            jQuery('[id*="fieldname'+'16_"]').closest('.fields').hide();
            return 'Maximale maat Polystyreen is 100×200 cm';
        }
    })()
    

    Best regards.

    Thread Starter Alwin

    (@wp-opti)

    Okay, I have added these code in the “Set Equation” field of the Calculated field but now I have one new problem:

    This code seems to be working in other (calculated) fields in the form too?

    I just want this code to work in one specific calculated field and not in all (calculated) fields in the whole form…

    Is that possible?

    Thank you,
    Alwin

    Plugin Author codepeople

    (@codepeople)

    Hello @wp-opti,

    The code will work only when the equation associated to the calculated field where you’ve inserted code is evaluated. The equations associated to a calculated fields are evaluated if and only if any of fields that are used in the equation varies its value, in this case, any of fields:

    fieldname2,fieldname6,fieldname41,fieldname42,fieldname43,fieldname44 and fieldname40

    Best regards.

    Thread Starter Alwin

    (@wp-opti)

    Okay, I think this code is not the solution I am after. Because it hides fieldname16 al the time and fieldname16 is the field that is showing the “total price” at the bottom of my form, so it is very important.

    Maybe there is one other solution:

    This is the code I am still using now:

    IF(AND(100>=fieldname2,200>=fieldname6,200>=fieldname41,100>=fieldname42,100>=fieldname43,100>=fieldname44),
    PREC(MAX(3.9,fieldname40*0.60+2.70),2), ‘Maximale maat Polystyreen is 100×200 cm’)

    So when one of the fieldnames meets one of the conditions, then the warning text ‘Maximale maat Polystyreen is 100×200 cm’ is displayed, which is good!

    But the calculation PREC(MAX(3.9,fieldname40*0.60+2.70),2) is also still performend and the result of this calculation is added up to the “total price” field.

    So maybe it is possible that when one of the conditions is activated that the calculation is not performend. Or that the value of the calculated field is just zero?

    Is that possible?

    Plugin Author codepeople

    (@codepeople)

    Hello,

    I guess you want that fields values are different than zero, and lesser than 100 or 200 depending on the variable, if it is the case the solution would be:

    
    IF(AND(0<fieldname2, fieldname2<=100,0<fieldname6,fieldname6<=200,0<fieldname41,fieldname41<=200,0<fieldname42,fieldname42<=100,0<fieldname43,fieldname43<=100,0<fieldname44,fieldname44<=100),PREC(MAX(3.9,fieldname40*0.60+2.70),2), 'Maximale maat Polystyreen is 100×200 cm')
    

    or even simpler:

    
    IF(AND(fieldname2, fieldname2<=100,fieldname6,fieldname6<=200,fieldname41,fieldname41<=200,fieldname42,fieldname42<=100,fieldname43,fieldname43<=100,fieldname44,fieldname44<=100),PREC(MAX(3.9,fieldname40*0.60+2.70),2), 'Maximale maat Polystyreen is 100×200 cm')
    

    Best regards.

    Thread Starter Alwin

    (@wp-opti)

    Thank you!

    With these 2 options there are no price calculatons at all anymore…

    I think the best solution for this problem is that ask for Custom Coding Service?

    Plugin Author codepeople

    (@codepeople)

    Hello @wp-opti,

    I guess that you should describe better the equation, with no code, only describe the equation, of course based on the fields’ names in the form, and include in the ticket the link to the webpage where the form is inserted for checking it in action.

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hidde fieldname’ is closed to new replies.