• Resolved alien123

    (@alien123)


    Dear CFF tech support,

    I am new to your plugin and I am experiencing a strange behavior. I have to add some quite complex math calculations to a CFF form of mine, so I had to add some custom Javascript code. As per your instructions I added an HTML content field with a <script> tag. Yesterday it was working, then at some point it started complaining that the functions declared in the HTML content field are not defined, and it hasn’t worked since. You can see the form here:

    https://www.bloomingstars.com/?cff-form=6

    If you click the “Calculate” button it complains that the “deg2rad function is not defined”, which it actually is, properly defined in an HTML content field of the same form. This was working yesterday.

    Any ideas as to what might have happened or I might be missing here?

    Thanks a bunch in advance

    ES

    • This topic was modified 3 years, 5 months ago by alien123.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @alien123

    There are some parser errors in your code. The issue is caused by the piece of code:

    function to360(alpha) {
        if (Math.abs(alpha) > 360)
            let alpha = 360 * (alpha / 360 - floor(alpha / 360));
    }
    return alpha;
    }
    

    There is an extra } parenthesis. Furthermore, the variable is passed as a function parameter, you cannot re-declare it into the function.

    So, the correct code would be:

    function to360(alpha) {
        if (Math.abs(alpha) > 360)
            alpha = 360 * (alpha / 360 - floor(alpha / 360));
        return alpha;
    }
    

    Please, note that it is your own code, not the plugin operations. The support service does not cover debugging the users’ projects. If you need additional help implementing your project, please contact us directly through the plugin website: Contact Us

    Best regards.

    Thread Starter alien123

    (@alien123)

    Hello,

    I am fully aware that tech support for the plugin doesn’t include custom code. Your timely response and help is greatly appreciated, even more so considering the request at hand.

    One has to always keep an eye out for such dumb mistakes. That’s why I hate JavaScript 🙂

    Thanks very much once again, I owe you one.

    ES

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

The topic ‘Custom javascript functions broken’ is closed to new replies.