Highlighted

Shipping address = Billing address [auto-populate]

Avatar

Avatar

struthious

Avatar

struthious

struthious

27-05-2009

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:

bill_addr

bill_city

bill_state

bill_zip

Check box name:

same_addr

Check box: 

               on/off

Check box binding:

On = 1

Off = 0

Mailing Address field names:

mail_addr

mail_city

mail_state

mail_zip

Mailing Address field codes:

mail_addr:

if (same_addr > 0) then (bill_addr) else $.rawValue = $.rawValue endif

mail_city:

if (same_addr > 0) then (bill_city) else $.rawValue = $.rawValue endif

mail_state:

if (same_addr > 0) then (bill_state) else $.rawValue = $.rawValue endif

mail_zip:

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”

Let me know if this helps.

LK

Replies

Highlighted

Avatar

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212
Steve_L_Walker

27-05-2009

This will get you going.

Steve

Highlighted

Avatar

Avatar

Jono_Moore

Total Posts

1.2K

Likes

109

Correct Answer

144

Avatar

Jono_Moore

Total Posts

1.2K

Likes

109

Correct Answer

144
Jono_Moore

27-05-2009

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:

if ($.rawValue==1) then

subformBillingAddress.presence = "visible"

else

subformBillingAddress.presence = "invisible"

endif

Highlighted

Avatar

Avatar

struthious

Avatar

struthious

struthious

26-01-2010

This is a belated thank you for taking the time to enter a better solution. I truly appreciate it, and I've applied the concept to other projects, making them more efficient too!