• Resolved teddyespo

    (@teddyespo)


    I want to create a Calculated Field (CF) with the following logic:

    If user enters 5000 or less into fieldname1, then I want this CF to display 100.

    If user enters anything higher than 5000 into fieldname1, then I want this CF to calculate 100 + 0.5%.

    Using the Equation Tutorial, I saw that I can make complex functions using Javascript. When I enter the following logic into the equation editor, it crashes the page that the form is published on:

    (function(){
    
    if(fieldname1 > 5000) return fieldname1*0.005+100;
    
    if(fieldname1 <= 5000) return 100;
    
    })();

    Can you please help?

    • This topic was modified 9 years, 1 month ago by teddyespo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter teddyespo

    (@teddyespo)

    Not sure what the problem was, but I fixed it. The only thing I did differently was take the extra line space out between the lines of code:

    (function(){
    if(fieldname1 > 5000) return fieldname1*0.005+100;
    if(fieldname1 <= 5000) return 100;
    })();
    Plugin Author codepeople

    (@codepeople)

    Hello @teddyespo,

    There are some plugins (not ours), that replace multiple symbols of lines changes by <BR> or <P>, breaking the Javascript code.

    Best regards.

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

The topic ‘Complex Javascript Formula Crashes the Page’ is closed to new replies.