• Resolved danniparedes

    (@danniparedes)


    I have been trying to use logic to have specific return values when the user inputs a number on “fieldname4” in CFF.

    This is my code:

    (function(){

    if(fieldname4 < 15000) return 4.72;

    if(fieldname4 > 15001 && fieldname4 <20000 ) return 4.25;

    if(fieldname4 > 20001 && fieldname4 <25000 ) return 4.25;

    if(fieldname4 > 25001) return 2.71;

    })();

    I just can not see the error and it’s driving me nuts, can anyone see the error in the code, the only return value I get right is 2.71.

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

    (@codepeople)

    Hello @danniparedes

    The equation can be implemented in a simpler way:

    
    (function(){
    
    if(fieldname4 < 15000) return 4.72;
    if(fieldname4 <20000 ) return 4.25;
    if(fieldname4 <25000 ) return 4.25;
    return 2.71;
    
    })();
    

    Furthermore, as the “return” for the second and third conditional statements are equals, the equation can be implemented as follows:

    
    (function(){
    
    if(fieldname4 < 15000) return 4.72;
    if(fieldname4 <25000 ) return 4.25;
    return 2.71;
    
    })();
    

    If the issue persists, please, send me the URL to the form’s page to check the equation in action.

    Best regards.

    Thread Starter danniparedes

    (@danniparedes)

    Thank you so much, that did it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with logic operators’ is closed to new replies.