• Resolved jdar

    (@jdar)


    I have two fields that need to talk one another, and I am stuck for a solution.
    Link to calculator
    (Click on “Tree Removal with or without its stump ground” then hit Next

    Here is my problem:
    If the user inputs any number into the “Trunk circumference” field, then touches anything else in the form, it resets.
    Trunk circumference code:
    `(function(){
    if(fieldname1 > 0) return prec(fieldname1*3.14,2);
    })();`

    The value only stays if the “Or, Trunk diameter” field is filled in. I need the value of the “Trunk circumference” to stay, if the user DOES NOT type anything into the “Or, Trunk diameter” field.

    My goal:
    Have the circumference calculated if the user enters in a diameter. If they don’t, then don’t do any calculations, and just use the inputted value of the circumference.

    Help would be severely appreciated. Thank you

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

    (@codepeople)

    Hello,

    Please, modifies the equation associated to the fieldname7 as follows:

    (function(){
    var v7 = jQuery('[id*="fieldname'+'7_"]').val()*1;
    if(fieldname1 > 0 &&  v7 == 0) return prec(fieldname1*3.14,2);
    else return prec(v7,2);
    })()

    Best regards.

    Thread Starter jdar

    (@jdar)

    You are truly an amazing individual! Thank you so much my friend!
    It works just as I need it to ??

    Plugin Author codepeople

    (@codepeople)

    Hello,

    In the next update of the plugin the process would be simpler, I’m implementing the use of the __ME__ constant.

    In the current version of the plugin if you use directly the name of the calculated field that is being evaluated in its own equation, you would be creating an infinite loop.

    For example, if you modify the equation as follows:

    (function(){
    if(fieldname1 > 0 &&  fieldname7 == 0) return prec(fieldname1*3.14,2);
    else fieldname7;
    })()

    the equatio and form will fail because the fieldname7 is the calculated field that is being evaluated.

    However, in the next version of the plugin you might use the constant __ME__ and the process would be safety:

    (function(){
    if(fieldname1 > 0 &&  __ME__ == 0) return prec(fieldname1*3.14,2);
    else __ME__;
    })()

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Calculated field problem’ is closed to new replies.