• Resolved radorp2p

    (@radorp2p)


    Hi, I want to show ”-” if the calculated value is < 0 (negative).

    if(fieldname4 == ‘choice1’ & fieldname11 > fieldname5) return -;

    It does not work. Basically if the fieldname is choice1 and fieldname11 is a higher number than fieldname5, it should give ”-”

    Or is there any other way I can show ”-” if the value is below 0?

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

    (@codepeople)

    Hello @radorp2p

    The return in this case, would be a text with the - symbol. In javascript the texts must be enclosed between quotes or double-quotes, as follows:

    (function(){
    if(fieldname4 == 'choice1' & fieldname11 > fieldname5) return '-';
    })()

    The previous equation is only an example. It does not include the cases where the condition in the conditional statement “if” is false.

    Best regards.

    Thread Starter radorp2p

    (@radorp2p)

    Can I use three conditions in one function like:

    if(fieldname4 == ‘choice1’ & fieldname11 > fieldname5 & fieldname8 == ‘choice2’) return ‘-‘;

    Is there any other way I can make it simply give ‘-‘ if result is below 0, without writing new functions.

    Plugin Author codepeople

    (@codepeople)

    Hello @radorp2p

    I’m sorry, my fault, I’ve copied and pasted your code, and I didn’t notice an error in your code.

    In javascript, the AND operator is the double ampersand symbol && the single ampersand is another operator.

    if(fieldname4 == 'choice1' && fieldname11 > fieldname5 && fieldname8 == 'choice2') return '-';

    For additional questions, I’ll need the link to your form to check your equation in action.

    Best regards.

    Thread Starter radorp2p

    (@radorp2p)

    Thanks so much! It works now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If value is < 0, show –’ is closed to new replies.