Support » Plugin: Calculated Fields Form » Populate forms from different pages

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

    (@codepeople)

    Hello @trucker

    The section you are referring to in the plugin’s documentation (https://cff.dwbooster.com/documentation#populate-form-b-with-a) describes how to fill form B with the information submitted by form A inserted on a different page. These forms are on different pages.

    Best regards.

    Thread Starter Trucker

    (@trucker)

    Hi, thank you a lot for the quick response!

    This is the example of the doc:

    [CP_CALCULATED_FIELDS_RESULT]
    <SCRIPT>
    cpcff_default = { 1 : {},2 : {} };
    cpcff_default[1][ 'fieldname3' ] = '<%fieldname1_value%>';
    cpcff_default[1][ 'fieldname7' ] = '<%fieldname2_value%>';
    cpcff_default[2][ 'fieldname2' ] = '<%fieldname1_value%>';
    cpcff_default[2][ 'fieldname3' ] = '<%fieldname2_value%>';
    </SCRIPT>
    [/CP_CALCULATED_FIELDS_RESULT]

    It mentions that “If there are two forms in the thank you page”
    It also says “These indices (or attributes) indicate the possition of the form in the page, the first form, index 1, second form, index 2, and so on.”

    so I am assuming these 2 forms are on the same page.

    Can you give me another example when the forms are on 2 different pages:

    1. Order Page
    2. Thank You Page

    Thank you a lot!

    Plugin Author codepeople

    (@codepeople)

    Hello @trucker

    The example you are requesting would be the same code in the plugin’s documentation.

    I’ll try to respond to your question about the consecutive numbers. Every form on a page has associated a consecutive number independently of its id. The first form on the page has number one as its consecutive number, the second form the number two, and soon.

    The reason is simple. You can insert the same form multiple times on a page. So, in this case, the use of form id would not be sufficient to differentiate them.

    Now, assuming you have two forms on the thank you page (their IDs no matter, ok?), and you want to populate the fieldname3 in the first form and the fieldname10 field in the second form with the value of the fieldname123 field submitted by a form on a different page.

    The shortcode for results in the thank you page would be similar to:

    [CP_CALCULATED_FIELDS_RESULT]
    <SCRIPT>
    cpcff_default = { 1 : {},2 : {} };
    cpcff_default[1][ 'fieldname3' ] = '<%fieldname123_value%>';
    cpcff_default[2][ 'fieldname10' ] = '<%fieldname123_value%>';
    </SCRIPT>
    [/CP_CALCULATED_FIELDS_RESULT]

    Best regards.

    Thread Starter Trucker

    (@trucker)

    Hi,
    Thank you a lot for the long reply!

    So how can it get the value of the form fieldname123_value from the different page?

    You say that “assuming you have two forms on the thank you page”.
    But what I want to do is to have 2 forms on 2 different pages.

    Let’s say

    I have form a on page A and form b on page B.

    Now, I want to want to populate the fieldname3a of the form a with the value of the fieldname3b of the form b.

    If I put the shortcode above to the page A, how could it find the determine where the form B is placed?

    Thank you once again!

    Plugin Author codepeople

    (@codepeople)

    Hello @trucker

    The page where you insert form B is irrelevant. You must enter the URL to the page where form A is inserted as the “thank you” page attribute of form B. And in the page of form A, you must insert the shortcode to populate its fields:

    [CP_CALCULATED_FIELDS_RESULT]
    <SCRIPT>
    cpcff_default = {1 : {}};
    cpcff_default[1][ 'fieldname3' ] = '<%fieldname3_value%>';
    </SCRIPT>
    [/CP_CALCULATED_FIELDS_RESULT]

    Best regards.

    Thread Starter Trucker

    (@trucker)

    Thank you a lot. I can now understand it!

    One more question,

    Assuming I have 2 forms on 2 different pages: Form a on page A, and form b on page B.

    The user enters a value to the field1 on form a, but they don’t press submit button. The data is stored via browser by the browser’s persistence function.

    After that, he moves to page B. Can I loads the value of the field1 on form a and show it in the field2 on form B?

    Thank you!

    Plugin Author codepeople

    (@codepeople)

    Hello @trucker

    No, I’m sorry. That’s not possible. These are different forms on different pages and cannot access the same persisted data.

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.