• Resolved freshrhino

    (@freshrhino)


    To generate the values in my results tab on the bottom I am using JavaScript in calculated forms. The Zavg and Tavg are variables I need to calculate flow or anything else. Right now I am calculating for Zavg and Tavg in multiple places but I would like to make all of those calculations in a single JavaScript code and then send the different variables to generate other fields that the user can see. Is something like this possible?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @freshrhino

    I’m not sure about your question. However, assuming you have the calculated field fieldname1, with the equation fieldname2+fieldname3, but you want to display the result into another field, the number field fieldname4, the equation should be edited as follows:

    (function(){
    var result = fieldname2+fieldname3;
    getField(4).setVal(result);
    return result;
    })()

    The getField operation requires the numeric part of the field’s name and returns its object representation.

    If you want to display the result into another tag, not a field, for example, a div tag with the class name result-here, the code of the equation would be:

    (function(){
    var result = fieldname2+fieldname3;
    jQuery('.result-here').html(result);
    return result;
    })()

    Best regards.

    Thread Starter freshrhino

    (@freshrhino)

    That does answer part of my question. Using your example.
    If I had

    Fieldname1 has the function below and I want to show the result there but I also want to take newfieldname2 variable out and show it in a different field. The reason I do not want to have a separate field to calculate newfieldname2 is because in my actual code I have to iterate through some variables to get my final solution.
    fieldname2 = 2;
    fieldname3 = 2;

    (function(){
    var newfieldname2 = fieldname2*10;

    var result = newfieldname2+fieldname3;
    return result;
    })()

    User should see there inputs for field and 2 and 3
    But the results would be
    fieldname1 = 22
    fieldname4 = 20 (which is a variable that was created in fieldname1)

    Thread Starter freshrhino

    (@freshrhino)

    Ok I played with the code you sent and it did answer my question. The setVal allowed me to change the value of another field based on whatever variable I wanted to send it. Thank you for the help! I can’t believe how fast you responded to that question by the way. Very helpful!

    Plugin Author codepeople

    (@codepeople)

    Hello @freshrhino

    Excellent !!!!

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use variables from calculated field to show in other fields’ is closed to new replies.