Support » Plugin: Calculated Fields Form » IF Logic Operator for String/Dropdown Menu?

  • Resolved luntuafrica



    I’m creating a grade calculator using CFF and am stuck on one small part. After calculating the base score, the calculator needs to add 2 points if the learner has chosen English as a subject.

    I’ve tried the following but none of them work (where fieldname4 is a dropdown menu, and English is the second option, with number values assigned for each option):

    +IF (fieldname4 = ‘ENGLISH’, 2, 0)
    +IF (fieldname4 = 2, 2, 0)

    In both cases, the Calculated Field fails to show any result at all. What am I missing and how can I fix it?

    Please help!
    Thanks in advance.

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


    Hello @luntuafrica

    Thank you very much for using our plugin.

    In javascript, the operator for the equality is the double symbol == because the single symbol = is used for assignment.

    So, the correct would be:

    +IF (fieldname4 == 'ENGLISH', 2, 0)

    However, if the choice’s value is the number 2, you need only:


    Best regards.

    Thread Starter luntuafrica


    Thank you so much! It worked (the == operator). Out of curiosity, in what instances would you use just one =?

    Plugin Author codepeople


    Hello @luntuafrica

    The = symbol is used for assignment. For example:

    var r = 0;
    if(fieldname1 == 'A') r = 3;
    if(fieldname1 == 'B') r = 6;
    if(fieldname1 == 'C') r = 9;
    return fieldname2+r;

    Best regards.

    • This reply was modified 6 months ago by codepeople.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘IF Logic Operator for String/Dropdown Menu?’ is closed to new replies.