I have a billing and shipping address section in my form. I want to add a checkbox that says "Same as Billing" which would automatically copy the field data from each field to corresponding fields in the shipping section. Is that possible?
Yes, this is indeed possible. To do this, you need to create a custom action in the "Same as Billing" checkbox element that would generate the copying of the fields.
Go to the checkbox element's properties => Advanced tab and scroll down to the Actionscript section.
TYPE: Custom
ACTIONS: Check the "Click" checkboxThen click on the "generate code framework" text. If a popup alert appears, click YES.
Into the generated function that appears in the textarea, right after this line:
case 'click':
Add this line for each element that you need to copy from the shipping section and add to the billing section:
ff_getElementByName('TARGET_ELEMENT').value = ff_getElementByName('SOURCE_ELEMENT').value;
(Replace TARGET_ELEMENT and SOURCE_ELEMENT with the names that you are using for the elements.)
For multiple elements, just repeat the line for each additional one you need to get the value for.
Click on the "Save Properties" button at the bottom of the screen to save your element changes, and then click on the SAVE icon in the upper right-hand corner of the screen to save the form itself.
Please test the following form which uses this code:
function ff_same_billing_shipping_action(element, action) { switch (action) { case 'click': if(element.checked){ ff_getElementByName('b_name').value = ff_getElementByName('name').value; ff_getElementByName('b_street').value = ff_getElementByName('street').value; ff_getElementByName('b_city').value = ff_getElementByName('city').value; } else{ ff_getElementByName('b_name').value =''; ff_getElementByName('b_street').value = ''; ff_getElementByName('b_city').value = ''; } break; default:; } // switch } // ff_same_billing_shipping_action