• Resolved vassevcom

    (@vassevcom)


    I want to make a return value in a calculation field under the following condition. If fieldname2=2 , the return value to be fieldname2*55+fieldname4 ; if fieldname2 =>3, the return value to be fieldname2*50; else fieldname2*59+fieldname4.
    I tried the following equation only for the condition “if fieldname2=2”, but nothing happened.
    (function(){
    if(fieldname2=2) return fieldname2*55
    })()

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

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

    (@codepeople)

    Hi,

    In javascript the comparison operator for equality is “==”, because the symbol “=” is used for assignment. So, your equation would be:

    (function(){
    if(fieldname2==2) return fieldname2*55+fieldname4;
    if(fieldname2>=3) return fieldname2*50;
    return fieldname2*59+fieldname4;
    })()

    Best regards.

    Thread Starter vassevcom

    (@vassevcom)

    Thanks! it works now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘if return value’ is closed to new replies.