• Resolved dianne92

    (@dianne92)


    Is it possible to display a custom message based on the calculated result?

    Say that I want to display a message based on the BMI result where you could say: You are overweight or Your are underweight based on the result.

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

    (@codepeople)

    Hello @dianne92

    Yes of course, you simply should to insert different “Instruct. Text” fields in the form with the corresponding texts, and define them as dependent on the equation’s results, from the settings of same calculated field. More information reading the following post of the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    Best regards.

    Thread Starter dianne92

    (@dianne92)

    Thank you for the quick response! I have the following form settings https://imgur.com/gallery/pKW1i5o and this preview https://imgur.com/pAQ7Gw0. How can I set the form so the fieldname26 or fieldname27 is only visible after I click the button and the calculation is made. Right now, fieldname26 is always showing and only changing to fieldname27 if the conditional if statement is fulfilled.

    On short, how to display the interpretation Instruct. Text only after the calculation is done?

    Plugin Author codepeople

    (@codepeople)

    Hello @dianne92

    You have defined the rule “less than 2”, and the value of calculated field is zero by default, in whose case the second rule would be valid and the fieldname26 field visible. So, the solution would be define the dependency rules manually, and comparing with the raw value of the field (and not only the processed one):

    1. Click on the “Edit rule manually” of second rule, and enter as the rule’s condition:

    
    value <= 2 && value|r != ''
    

    2. And then, select the fieldname26 from the list of dependent fields.

    Best regards.

    Thread Starter dianne92

    (@dianne92)

    Did not fully understood what the value|r != '' does but it works now so I’m one step closer to achieving a really neat form.

    Now the issue I see is that even if I have selected the Required option for each of the Checkboxes, when I load the form for the first time, I can click the Get Results button to start the calculation and I even get the 0 result without having to check any of the checkboxes associated with my questions. Furthermore, I can (for example) only check 2 questions and still get a result. Even more, only if I check and then uncheck the checkboxes I get a red This field is required. error.

    This is the post where it’s now used: https://www.hlbenefits.com/silent-acid-reflux-manifestation-treatment-research/

    Plugin Author codepeople

    (@codepeople)

    Hello @dianne92

    The validation rules are applied only when the form is submitted, and not when the equation’s are evaluated. If you want to evaluate the equations only if the fields’ validations rules are satisfied, an alternative would be edit the equation as follows:

    
    (function(){
    if(getField(9).jQueryRef().closest('form').valid())
    return fieldname28+fieldname30+fieldname29+fieldname35+fieldname36+fieldname37+fieldname38+fieldname41+fieldname12;
    })()
    

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display custom message based on calculation result’ is closed to new replies.