• Resolved 314em

    (@314em)


    HI CodePeople!

    Really enjoying using your plugin. It helped speed through a form creation.

    My page is currently set up like this:
    Form A – users input data
    Form B – users input data
    Form C – users input data
    Form D – gather data from the 3 forms which are on the same page, apply some formulas and show these results as a summary.

    For the input fields I have predefined values which means my summary on page load contains calculated values (working correctly and as expected).

    But after I refresh the page, calculation becomes 0, until I change all the values from form A-C.

    I tried playing with the plugins Script load method (Direct/ Classic) but no luck.

    Any help is appreciated.
    Thank you.

    • This topic was modified 2 years, 5 months ago by 314em.
Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter 314em

    (@314em)

    Update: I think it has to do with the order of execution. If I refresh multiple times there are chances to get the calculations done.

    Is there a way to prioritize the calculations and then show the summary? (without using a button)

    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    If you have multiple forms on your page, you cannot controlling the order in which they are rendered or their equations are evaluated.

    A solution would be to include a setTimeout in the last form to evaluate its equation after some seconds.

    For example, assuming you are generating the summary with an equation in the form, you can:

    1. Assign a class name to the form. If the form that generates the summary has id="1" you can insert its shortcode with the class attribute:

    [CP_CALCULATED_FIELDS id="1" class="summary-form"]

    2. Insert an “HTML Content” field in the form with the following piece of code as its content:

    <script>
    setTimeout(function(){
    EVALEQUATIONS(jQuery('.summary-form'));
    }, 5000);
    </script>

    Best regards.

    Thread Starter 314em

    (@314em)

    Hi CodePeople,

    Thanks for the answer.
    Tbh I spent the last day trying to figure out where can I assign the class attribute.

    When I place it within divi’s text module [CP_CALCULATED_FIELDS id=”10″ class=”summary-form’] it does not work (nor does it show up in console).

    What obvious thing I am missing? ??

    • This reply was modified 2 years, 5 months ago by 314em.
    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    You are merging quotes and double quotes, the correct would be:

    [CP_CALCULATED_FIELDS id="10" class="summary-form"]

    Best regards.

    Thread Starter 314em

    (@314em)

    Ah, that was just a simple error when writing here.

    In the divi I have it correctly.

    Summary:
    Divi theme text module I have:
    [CP_CALCULATED_FIELDS id="10" class="summary-form"]

    In CFF
    I have an HTML module with

    <script>
    setTimeout(function(){
    EVALEQUATIONS(jQuery('.summary-form'));
    }, 50000);
    </script>

    *added 50000 as a desperate value ??

    I have 7 fieldnames that are hidden (these are values from prev forms.)
    I have another 8 hidden fields where I do calculations using the above fields.

    I have one HTML code with some summary text and calculated fields.
    And a summary module.

    I would love the summary and the HTML to be “rendered” last.

    Thanks for your patience!

    • This reply was modified 2 years, 5 months ago by 314em.
    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    I guess your Divi is transforming the double quotes into invalid quotes.

    Please, insert the shortcode with no quotes:

    [CP_CALCULATED_FIELDS id=10 class=summary-form]

    And please, include a screenshot of the shortcode inserted on the page.

    Best regards.

    Thread Starter 314em

    (@314em)

    Screenshot

    ^Obviously now without quote marks as you suggested. However I was expecting the shortcode to appear also in the CFF plugin, here for example

    • This reply was modified 2 years, 5 months ago by 314em.
    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    If you want to use quotes, you should insert the shortcode into the “Text” tab (https://ibb.co/NjNdYjz), and not the “Visual” tab.

    Best regards.

    Thread Starter 314em

    (@314em)

    Thanks CodePeople,

    Did that, unfortunately with no luck.

    I think, a workardound would be to use a button, but that would kill the fun for the form.

    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    How could I check the forms in action?

    Best regards.

    Thread Starter 314em

    (@314em)

    Use this link please.

    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    I checked your form, and the equations are evaluated 10 seconds after loading the forms, just like you defined with the piece of code:

    <script>
    setTimeout(function(){
    EVALEQUATIONS(jQuery('.summary-form'));
    }, 10000);
    </script>

    Best regards.

    Thread Starter 314em

    (@314em)

    Hi codepeople,

    Well, that can’t be right, as the code/ summary is instantly shown.

    Summary form is the last one, and technically it should be empty (no data in it) for 10 seconds, yet on load it’s already there with either 0 or the correct data.

    Kind regards

    Plugin Author codepeople

    (@codepeople)

    Hello @314em

    If you don’t want to generate the summary immediately, please, follow the steps below:

    1. Untick the “Dynamically evaluate the equations associated with the calculated fields” checkbox in the “Form Settings” tab of your form (https://resources.developers4web.com/cff/images/documentation/form-settings-tab.png).

    2. Edit the piece of code in the “HTML Content” field as follows:

    <script>
    setTimeout(function(){
    var f = jQuery('.summary-form');
    ENABLEEQUATIONS(f);
    EVALEQUATIONS(f);
    }, 10000);
    </script>

    Best regards.

    Thread Starter 314em

    (@314em)

    Hi CP,

    I do want dynamic calculation, but I also want it to be calculated for the default (predefined values).

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Fields not being calculated after refresh’ is closed to new replies.