Support » Plugin: Calculated Fields Form » Formula result on multiple textbox

  • Resolved WPReady

    (@wpready)


    I have a complex formula which gets data from 4 input fields, makes the calculation and the result is returned using different values.

    Is it possible one formula populate 3 fields, one for every part of the solution?

    I don’t know if it’s even possible. Otherwise would you suggest a workaround?

    Thank you

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

    (@codepeople)

    Hello @wpready,

    Yes, that’s possible and there are different solutions depending on the equation and the type of fields, for example, assuming that you want sum three fields: fieldname1, fieldname2, and fieldname3, and you want assign the result the fields: fieldname4, fieldname5 and fieldname6, and assuming that the fieldname4 is a calculated field, the equation can be implemented as follows:

    
    (function(){
    var result = fieldname1+fieldname2+fieldname3;
    
    jQuery('[id*="fieldname'+'5_"]').val(result).change();
    jQuery('[id*="fieldname'+'6_"]').val(result).change();
    
    return result;
    })()
    

    and that’s all.
    Best regards.

    Thanks this is working exactly as you said.
    I wonder why is the concatenation ‘[id*=”fieldname’+’5_”]’ .
    I tested in other ways and none would work.

    Thank you again!

    Plugin Author codepeople

    (@codepeople)

    Hello @wpready,

    The concatenation is required because the plugin parse the equations and replace the texts with the format: fieldname# with the corresponding field’s value, using the concatenation, I break the structure the plugin replaces, accessing to field.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Formula result on multiple textbox’ is closed to new replies.