Global Constants Are Possible? | WordPress.org

[ad_1]

Hi! I’ve searched but had no luck finding an answer. I was hoping to define “global ” constants (global to a single form, to be used by fields for calculations).

I created an HTML element in the (top of) form and tried this:

<script> const CONST_CNF_CAP = 0.03003, CONST_LNF_IND = 0.02252, CONST_RZ_RES = 1.25;
</script>

And then within a field, for example, attempted to use it like so:
(function(){
var result;
result = CONST_CNF_CAP/fieldname14;
return PREC(result*1000000,1);
})()

…with no success. Is it possible to do this in a form?

Thank you! 🙂

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer