• Resolved strongtyer

    (@strongtyer)


    I am building a pricing page where I need to sum the results of form A and form B in a total section outside form A/B.

    If we use the [CP_CALCULATED_FIELDS_RESULT] method described in the documentation,

    1. How can we pull values from forms A and B into form C?
    2. Does this update live or only on submit? How is submit being defined?

    OR

    Is there a better way all together to sum two values from two different forms?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter strongtyer

    (@strongtyer)

    Here is an image for reference:

    https://photos.app.goo.gl/QonF314vhsYg2deR6

    Plugin Author codepeople

    (@codepeople)

    Hello @strongtyer,

    In the equations associated to the calculated fields are used fields in the same form, so, if you want use fields in different forms, and evaluate the equations dynamically, as soon as these fieds vary their values, you should follow some tricks (something different would be if you don’t need the equations be evaluated dynamically in the third form, and you use a button field for triggering the evaluation of the equations):

    First, in the form A, assign an unique class name to the field that will be used in the form C, for example: my-field-a

    Note that the class names are assigned to the fields through their attributes: “Add CSS Layout Keywords” (in the fields’ settings)

    Second, assign an unique class name to the corresponding field in the form B: my-field-b

    Third, insert two hidden fields in the form C, I’ll call them fieldname1 and fieldname2, and will assign them the class names: field-from-a, field-from-b

    Fourth, insert a “HTML Content” field in the form C with the following piece of code as its content:

    
    <script>
    jQuery(document).on('change', '.my-field-a input', function(){jQuery('.my-field-from-a input').val(this.value).change();});
    
    jQuery(document).on('change', '.my-field-b input', function(){jQuery('.my-field-from-b input').val(this.value).change();});
    </script>
    

    Finally, in the calculated fields in the form C you use the hidden fields: fieldname1 and fieldname2 as usual, because they are in the form C and their values are populated with the values of the corresponding fields in the forms A and B.

    This previous code does not have relationship with the shortcode: [CP_CALCULATED_FIELDS_RESULT], even the previous code us supported by the free version of the plugin.

    Concerning to the submit button. The free version of the plugin does not include the server side modules for storing the collected information in the website’s database, send the notification emails or integrate the form with a payment gateway, for this reason the attribute: “Display submit button?” in the form’s settings is disabled.

    Does mean you cannot insert a submit button with the free version of the plugin?

    Not really, with the free version of the plugin you can insert a submit button in two different ways:

    – Inserting a common button in the field, and entering as its onclick event the piece of code:

    jQuery(this).closest('form').submit();

    – Or inserting a “HTML Content” field in the form with the input tag as its content:

    <input type="submit" value="Submit the form" />

    However, with the free version of the plugin the server side code that manage the data submitted by the forms should be implemented by yourself.

    Note that with the Professional version of the plugin insert a submit button is as simple as select the “Yes” option for the attribute: “Display submit button?” in the form’s settings.

    Best regards.

    Thread Starter strongtyer

    (@strongtyer)

    This is perfect. Thank you so much.

    We ran into some issues with the values not being set on load and the calculations in form C, but were able to work through it. This got us 90% of the way there.

    Plugin Author codepeople

    (@codepeople)

    Hello @strongtyer,

    It has been a pleasure.

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Passing values from forms A and B to C’ is closed to new replies.