Title: Define extra Javascript functions
Last modified: August 22, 2016

---

# Define extra Javascript functions

 *  Resolved [hotcore](https://wordpress.org/support/users/hotcore/)
 * (@hotcore)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/define-extra-javascript-functions/)
 * Hi again,
 * is it possible to define one’s own named functions somewehere (where?), which
   can be called from an anonymous function in a calculated field?
 * TIA,
    Arie
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/define-extra-javascript-functions/#post-5829191)
 * Hi,
 * Yes of course, please read the answer to the question: “Q: How to include my 
   own javascript files to implement my own operations?”, in the FAQ page of the
   plugin:
 * [https://wordpress.org/plugins/calculated-fields-form/faq/](https://wordpress.org/plugins/calculated-fields-form/faq/)
 * Best regards.
 *  Thread Starter [hotcore](https://wordpress.org/support/users/hotcore/)
 * (@hotcore)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/define-extra-javascript-functions/#post-5829221)
 * Supplementary question:
 * I wanted to add this function:
 * function norm(cd, v2, kd, f){
    var rc = 0; var yd = 0; if (f != 0) { yd = FLOOR(
   ABS(cd – f) / 365); if (yd > 17) {rc = rc + v2;} else {rc = rc + kd;}; } return
   rc; }
 * So, I created a norm.js file in the public js directory as described in the FAQ,
   but it does not work.
 * In the predefined .js files there is a special syntax. Do I need that? Is it 
   described somewhere?
 * Thanks very much for the help. Hope i’ll get the hang of it soon.
 * Best, Arie
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/define-extra-javascript-functions/#post-5829226)
 * Hi,
 * If you want the function has a global scope, define it like:
 * window[ ‘norm’ ] = function (cd, v2, kd, f){
    var rc = 0; var yd = 0; if (f !
   = 0) { yd = FLOOR(ABS(cd – f) / 365); if (yd > 17) {rc = rc + v2;} else {rc =
   rc + kd;}; } return rc; }
 * Best regards.

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

The topic ‘Define extra Javascript functions’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/define-extra-javascript-functions/#post-5829226)
 * Status: resolved