Title: Custom javascript functions broken
Last modified: January 12, 2023

---

# Custom javascript functions broken

 *  Resolved [alien123](https://wordpress.org/support/users/alien123/)
 * (@alien123)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-functions-broken/)
 * 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](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](https://wordpress.org/support/users/alien123/).

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-functions-broken/#post-16368307)
 * Hello [@alien123](https://wordpress.org/support/users/alien123/)
 * There are some parser errors in your code. The issue is caused by the piece of
   code:
 *     ```wp-block-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:
 *     ```wp-block-code
       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](https://cff.dwbooster.com/customization)
 * Best regards.
 *  Thread Starter [alien123](https://wordpress.org/support/users/alien123/)
 * (@alien123)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-functions-broken/#post-16370984)
 * 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.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [alien123](https://wordpress.org/support/users/alien123/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-functions-broken/#post-16370984)
 * Status: resolved