0

Using FreeForm Pro. I have a 2 page multipage form set up. On the first page users insert their address details. On the second page of the form I want to have a check box and if the user checks the box the address details from the first page are inserted into the address details on the second page. Similar to when you can choose your billing address to be used as your shipping address.

The problem I'm having is achieving this. I'm using javascript to try and fill the form fields on click (using a similar method to this: http://jsfiddle.net/aDNH7/) but because i'm using the {freeform:field:address_line_1_p2} to create the field rather than hand coding the field, (as i need the data to remain on refresh ie for inline errors), I cant use {freeform:mp_data:address_line_1_lb} for example to insert into {freeform:field:address_line_1_p2 } as the data value.

Can anyone offer a solution or advice? Many thanks, Ian

0

There might be more than one way around this, but it comes down to javascript and how you set up your elements. First, simply confirming that the data from the previous form page (page 1) can be retrieved using {freeform:mp_data:MY_FIELD_FROM_PAGE1}.

On page 2, on your {freeform:field:MY_FIELD_FOR_PAGE2} field, you could try the default_value="" parameter (see http://www.solspace.com/docs/freeform/form/#freeform_field_field_name) and place {freeform:mp_data:MY_FIELD_FROM_PAGE1} as the parameter value. Eg.

{freeform:field:MY_FIELD_FOR_PAGE2 default_value="{freeform:mp_data:MY_FIELD_FROM_PAGE1}"}

Parse order might get in the way, but it's worth a try. Everything would be in place from the start, and you could also add attr:disabled="disabled" to your {freeform:field:MY_FIELD_FOR_PAGE2} fields so that they are disabled unless your special checkbox is checked.


Another approach could be to store your page 1 data into hidden elements, and copy the data over, using javascript/jQuery, to your page 2 fields after checking your checkbox. What would link both elements could be a matching class name. Eg:

<input type="hidden" class="origin my_field_from_page1" disabled="disabled" value="{freeform:mp_data:MY_FIELD_FROM_PAGE1}" /> <input type="text" name="MY_FIELD_FOR_PAGE2" class="target my_field_from_page1" value="" />

Since both fields have the same class name, javascript/jQuery could take care of copying the value in the input.origin field over to the input.target (i.e. take the value of the origin field and copy it to a target field with a matching class of X). Instead of classes, you could alternatively use data- attributes as well. Many ways for this to work.

1
  • Hi Solspace. Thanks very much for your help. You were right the first solution didn't work because of the parse order. So I opted for the approach using hidden fields to bring the data in and then used javascript to populate the target fields when the checkbox was checked. – Erbert Oct 20 '14 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.