• Resolved compasstourist

    (@compasstourist)


    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

    (@codepeople)

    Hello @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

    (@compasstourist)

    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

    (@codepeople)

    Hello @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.