There may be more graceful ways to code this (I'm new to formcalc). If anyone has a better way please chime in. I'm posting it because I didn't find any resources on it and thought it might save someone else some time.
Billing Address field names:
Check box name:
Check box binding:
On = 1
Off = 0
Mailing Address field names:
Mailing Address field codes:
if (same_addr > 0) then (bill_addr) else $.rawValue = $.rawValue endif
if (same_addr > 0) then (bill_city) else $.rawValue = $.rawValue endif
if (same_addr > 0) then (bill_state) else $.rawValue = $.rawValue endif
if (same_addr > 0) then (bill_zip) else $.rawValue = $.rawValue endif
explanation -- if the “same_addr” box is checked it’s “on” with a value equal to 1 (greater than zero) then the billing field will populate with data from its corresponding mailing field, or the “else” statement means “it is what it is”
You can definitely streamline things so it's easier to maintain.
I'd put all the code in one if statement on the change event of the checkbox:
if ($.rawValue==1) then bill_addr.rawValue = mail_addr.rawValue bill_city.rawValue = mail_city.rawValue bill_state.rawValue = mail_state.rawValue bill_zip.rawValue = mail_zip.rawValue endif
I don't think I'd bother with the else statements setting the rawValue - if the billing address is the same people will click the button, if it's not the same they'll fill in the info.
Depending on what your form looks like you could also set it up with a hidden subform for the billing info if needed - something along the lines of a checkbox that says "Enter Separate Billing Address?" and then: