Support » Plugin: Calculated Fields Form » Formula help

  • Resolved EliteWebServices

    (@elitewebservices)


    I have a question. I’m working on a form which has 3 input fields and one calculated field. I would like the user to enter any 2 fields to get the calculated field result. I realize I would need 3 different formulas in the background but how would I setup the logic to perform this situation? Would I use the “or” function also what would the syntax look like?

    Thanks in advance

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @elitewebservices,

    I will try to describe the process with a hypothetical example:

    – Assuming the input fields are the fieldname1 and fieldname2, and you want to implement the following equation:

    * If fieldname1 and fieldname2 are both greater than or equal to 100, the equation would be: fieldname1+fieldname2

    * If only fieldname1 is greater than or equal to 100, the equation would be: fieldname1-fieldname2

    * And if only fieldname2 is greater than or equalt to 100, the equation would be: fieldname2-fieldname1

    The equation in this hypothetical example would be:

    
    (function(){
    if(100<=fieldname1 && 100<=fieldname2) return fieldname1+fieldname2;
    if(100<=fieldname1) return fieldname1-fieldname2;
    if(100<=fieldname2) return fieldname2-fieldname1;
    })()
    

    and that’s all.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Formula help’ is closed to new replies.