Viewing 5 replies - 1 through 5 (of 5 total)
  • There are three ways to use conditional statements in the equations:

    Using the IF operation (don’t confuse the operation “IF” with the reserved word “if” of javascript, the code in javascript is case sensitive)

    IF( condition, value if true, value if false)

    For example, if the result of the equation is 100 when the value of fieldname1 is less than 100 and 1000 in another case, the equation would be:

    IF(fieldname1<100,100,1000)

    Using the ternary operator of javascript

    (condition) ? value if true : value if false

    Following the same example in the previous point:

    (fieldname1<100) ? 100 : 1000

    With a more powerful equation

    (function(){
    if( fieldname1 < 100) return 100;
    else return 1000;
    })()

    If my four year old had written this I’d be packing him off to Silicone Valley and requesting early retirement. I would say the developers of this free plugin have invested plenty of quality time and effort in supporting the plugin through detailed FAQs and multiple responses here to various common scenarios.

    IMO this is an excellent and powerful calculating form plugin – up there as one of the best in its field in the repository. As with any non plug-and-play plugin it requires takes careful reading of the documentation, trial-and-error experimentation, and if all else fails, a polite request to the developers for advice.

    Good luck!

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’m sorry for the delay answering to your question. The reason that your equation is failing, is really simple:

    IF(fieldname2<55000,fieldname2*0.005)

    The operation IF has three parameters: the condition, the value to return if the condition is true, and the value to return if the condition is false. You have omited the third parameter. So, if the value of fieldname2 is bigger than 55000, the operation result would be empty.

    Best regards.

    Thread Starter HappyListing

    (@happylisting)

    Im sorry thats not a sufficient answer.

    Both IF statements do not have the false condition so how do you explain that?

    Why doesn’t the documentation have many examples not just how to calculate 1+1 because it seems that’s what this plugin is only good for.

    Thread Starter HappyListing

    (@happylisting)

    Ok I was able to get it but no thanks to your “documentation”

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    What was unclear about this?

    The operation IF has three parameters: the condition, the value to return if the condition is true, and the value to return if the condition is false.

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

The topic ‘If statements’ is closed to new replies.