Shipping address = Billing address [auto-populate]

Avatar

Avatar
Level 1
struthious
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
struthious
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile
struthious
Level 1

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

Avatar

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

198 likes

Total Posts

1,435 posts

Correct reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

198 likes

Total Posts

1,435 posts

Correct reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Steve_L_Walker
Level 9

27-05-2009

This will get you going.

Steve

Avatar

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
Jono_Moore
Level 8

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

Avatar

Avatar
Level 1
struthious
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
struthious
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile
struthious
Level 1

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!