• Resolved crayoya

    (@crayoya)


    Hello! Thanks for you plugin! Need some help please

    Trying to input a code with multiple conditions (it is quite hard for me, no experience)

    already tried it as function according to tutorial https://wordpress.dwbooster.com/includes/calculated-field/equations.html ,

    but it does not work

    <(function(){
    
    if((fieldname2 <= 1.03) and(fieldname3 < 2.5) and(fieldname4 < 1.1)) return 2
    
    })();

    this is only one of IFS i need to put in this field but it doesnt work so i need some example or correction please

    • This topic was modified 5 years, 1 month ago by crayoya.
Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @crayoya

    In javascript, the “and” operator is represented by the double ampersand symbol: &&, so, the equation would be:

    (function(){
    if( fieldname2 <= 1.03 && fieldname3 < 2.5 && fieldname4 < 1.1) return 2;
    })();

    Pay attention too, to the semicolon symbol at the end of code line.

    Another alternative would be the use of the “AND” operation distributed with the plugin: AND(x,y,z,…..)

    
    (function(){
    if( AND(fieldname2 <= 1.03, fieldname3 < 2.5, fieldname4 < 1.1)) return 2;
    })();
    

    A third alternative of the same equation, would be using the “IF” operation distributed with the plugin (instead of the javascript conditional statement “if”), in whose case won’t be required the structure of function:

    
    IF(AND(fieldname2 <= 1.03, fieldname3 < 2.5, fieldname4 < 1.1), 2, '')
    

    and that’s all.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Difficulties with logical calculations’ is closed to new replies.