• Resolved Jay Collier

    (@jcollier)


    We have 6 calculated fields with varying values depending on responses to previous fields. We’d like to display specific HTML-formatted text (including a link) based on which calculated field has the largest numeric value. Are there specific topics in the support documents that would answer this question?

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

    (@codepeople)

    Hello @jcollier

    You have multiple alternatives to implement the described behavior.

    I’ll try to describe the process with a hypothetical example.

    Assuming you have three calculated fields, fieldname1, fieldname2, and fieldname3.

    If fieldname1 has the largest value, you want to display the text:

    Answer A. <a >Click Here</a>

    If fieldname2 has the largest value, you want to display the text:

    Answer B. <a >Click Here</a>

    And the text below if the largest value is associated with the fieldname3:

    Answer A. <a >Click Here</a>

    First, insert an additional calculated field in the form to use as an auxiliary (I’ll assume it is the fieldname4). You can hide it by ticking a checkbox in its settings. And enter the equation:


    (function(){
    let value = fieldname1;
    let result = 'Answer A. <a >Click Here</a>';

    if(value < fieldname2) {
    value = fieldname2;
    text = 'Answer B. <a >Click Here</a>';
    }

    if(value < fieldname3) {
    value = fieldname3;
    text = 'Answer C. <a >Click Here</a>';
    }

    return text;
    })()

    Finally, insert an “HTML Content” field in the form where display the text, and enter a DIV tag as its content with the data-cff-field attribute to tell the plugin the field whose value you want to display in the tag:

    <div data-cff-field="fieldname4"></div>

    Best regards.

    Thread Starter Jay Collier

    (@jcollier)

    Thank you for the rapid and clear response! I will implement as you recommended.

    One question: what formula would I use to determine which value is the largest of the 3 in your example? (Disregard; let me work through that formula until I understand how it works.)

    • This reply was modified 1 month, 2 weeks ago by Jay Collier.
    Thread Starter Jay Collier

    (@jcollier)

    Thank you for that very elegant solution! We tweaked a bit and it worked perfectly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.