• Resolved renslakens

    (@renslakens)


    Hi,

    I had the function:

    Fieldname7 is radio button and fieldname 5 and 6 are numbers.

    (function(){
       var result = '';
       if(fieldname7 == Yes){
            0,14*(fieldname5-fieldname6)
        } else {
            fieldname6
        }
        return result;
    })()

    But I can’t get it to work.

    Thanks for the help

    • This topic was modified 3 years, 7 months ago by renslakens.
Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @renslakens

    There are some issues with your equation.

    * The literal text must be enclosed between single or double quotes.
    * The decimal symbol is the dot and not the comma.
    * The lines of code must end with a semicolon.
    * You must assign the result of the mathematical operations to the “result” variable that you return at the end of the equation.

    So, the equation would be:

    (function(){
       var result = '';
       if(fieldname7 == 'Yes'){
            result = 0.14*(fieldname5-fieldname6);
        } else {
            result = fieldname6;
        }
        return result;
    })()

    The equation can be simplified by using the IF operation (do not confuse with the if conditional statements of javascript) as follows:

    IF(fieldname7 == 'Yes', 0.14*(fieldname5-fieldname6), fieldname6)

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Radio button calculation’ is closed to new replies.