• Resolved ti999

    (@ti999)


    Hello, I would like to know how I can do a calculation, using an IF condition.

    I have a checkbox field labaled gender, with the options male and female. Based on the option selected, a different calculation is made.

    Like if fieldname5(gender) = ‘male’ then do calculation. And the same for female, with a different calculation.

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @ti999

    Thank you very much for using our plugin.

    You have multiple alternatives to implement the equation with conditionals.

    Using the IF conditional operation in the plugin:

    IF(fieldname5 == 'male', fieldname1+fieldname2, fieldname3+fieldname4)

    Using if conditional statement. Javascript is a case-sensitive programming language. Please, do not confuse the IF conditional operation in the plugin with the if conditional statement of Javascript:

    (function(){
    if(fieldname5 == 'male') return fieldname1+fieldname2, else return fieldname3+fieldname4;
    })()

    Using the Javascript ternary operator:

    (fieldname5 == 'male') ? fieldname1+fieldname2 : fieldname3+fieldname4

    Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Do a Calculation with an IF statement’ is closed to new replies.