Title: Accessing javascript variables in calculated field
Last modified: May 23, 2022

---

# Accessing javascript variables in calculated field

 *  Resolved [compasstourist](https://wordpress.org/support/users/compasstourist/)
 * (@compasstourist)
 * [4 years ago](https://wordpress.org/support/topic/accessing-javascript-variables-in-calculated-field/)
 * Hi, I want to be able to calculate some javascript variables based on inputs.
   This is fine, I can see that my variables are correctly populated using event
   handlers. However, I cannot get my separate calculated input to refresh based
   on these variables – is this possible?

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [4 years ago](https://wordpress.org/support/topic/accessing-javascript-variables-in-calculated-field/#post-15671047)
 * Hello [@compasstourist](https://wordpress.org/support/users/compasstourist/)
 * Yes, that’s possible, but you should force the evaluation of the second equation.
   For example, assuming you have two calculated fields, fieldname123 and fieldname456.
   The equation of the fieldname123 field generates a global javascript variable(
   It is a hypothetical example):
 *     ```
       (function(){
       my_global_variable = fieldname1*fieldname2;
       return my_global_variable+fieldname3;
       })()
       ```
   
 * And you want to use the my_global_variable variable in the equation of the fieldname345.
   So, you must trigger the second equation from the first one:
 *     ```
       (function(){
       my_global_variable = fieldname1*fieldname2;
       EVALEQUATION(456);
       return my_global_variable+fieldname3;
       })()
       ```
   
 * The EVALEQUATION operation receives as a parameter the number component in the
   field’s name whose equation you want to evaluate.
 * Best regards.
 *  Thread Starter [compasstourist](https://wordpress.org/support/users/compasstourist/)
 * (@compasstourist)
 * [4 years ago](https://wordpress.org/support/topic/accessing-javascript-variables-in-calculated-field/#post-15671087)
 * Thanks so much and appreciate the speedy response.
 * Yes that works great! (although for anyone else finding this answer I had to 
   tweak it slightly to `EVALEQUATION(document.getElementsByTagName("form")[0], 
   456)`)
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [4 years ago](https://wordpress.org/support/topic/accessing-javascript-variables-in-calculated-field/#post-15671094)
 * Hello [@compasstourist](https://wordpress.org/support/users/compasstourist/)
 * You should pass the form object only if there are multiple forms generated with
   our plugin on the page.
 * Best regards.

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

The topic ‘Accessing javascript variables in calculated field’ 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: [4 years ago](https://wordpress.org/support/topic/accessing-javascript-variables-in-calculated-field/#post-15671094)
 * Status: resolved