• Resolved Javy26

    (@javy26)


    Thanks for this plugin, really awesome. Am trying to figure out what am doing wrong. I have a field named “total charges” what I want is for it to be determined by what users entered in “fieldname2.” if the number entered in fieldname2 is <=50 then it should be fieldname2*1 else if the number is >50 thne it should be fieldname2*fieldname2. This is the formula I have:

    (function(){
    
    if (fieldname2<=50)return fieldname2*1;}
    else if(fieldname2>50)return fieldname2*2;}

    What am I doing wrong?

    https://wordpress.org/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    You have entered in the equation an additional curly brace symbol, and have not used the correct format for the function. Please, uses the following equation:

    (function(){
    if(fieldname2<=50) return fieldname2*1;
    else if(fieldname2>50) return fieldname2*2;
    })()

    Best regards.

    Thread Starter Javy26

    (@javy26)

    Thank you

    Thread Starter Javy26

    (@javy26)

    is there a way to implement a button? Meaning when clicked it performs the calculations

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes of course, please, follows the steps below:

    1. Activates the “Form Settings” tab, in the forms builder, and untick the checkbox: “Eval dynamically the equations associated to the calculated fields”

    2. Insert a button in the form, and then in its attributes, tick the option: “calculate” as the button type.

    and that’s all.
    Thank you very much for using our plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If statement’ is closed to new replies.