Skip to main content
D Heg
Participant
November 14, 2018
Answered

How to make the bill to address auto populate the ship to address if a checkbox is checked?

  • November 14, 2018
  • 1 reply
  • 1023 views

Hello,

I'm creating a form in which if someone fills out the bill to section of the form and checks our "Same As  Bill To" check box, then all the rest of the fields will auto populate. So far I have had no luck executing this.

My check box is named "SameAsBillTo", and if it's checked I want all the following field names to equal each other:

Customer name2 ("CustomerName2") = Customer Name1 ("CustomerName1")

"Street2" = "Street1"

"City2" = "City1"

"State2" = "State1"

"Zip2" = "Zip1"

"Contact2" = "Contact1"

"ContactEmail2" = "ContactEmail1"

"ContactPhone2" = "ContactPhone1"

I have minor experience using javascript editor but, previously I have been successful using it for formulas. I researched this question on a bunch of other forums and have tried coping similar codes and have matched it with mine, but nothing has worked yet.  Below is an example of my current code:

if(SameAsBillTo=="Yes"){

this.getField("CustomerName2").value = this.getField("CustomerName1").valueAsString;

this.getField("Street2").value = this.getField("Street1").valueAsString;

this.getField("City2").value = this.getField("City1").valueAsString;

this.getField("State2").value = this.getField("State1").valueAsString;

this.getField("Zip2").value = this.getField("Zip1").valueAsString;

this.getField("Contact2").value = this.getField("Contact1").valueAsString;

this.getField("ContactEmail2").value = this.getField("ContactEmail1").valueAsString;

this.getField("ContactPhone2").value = this.getField("ContactPhone1").valueAsString;

}

Note - "SameAsBillTo" is my check box

Am I on the right path and just messing up the code? Or is there a total different code I need to use? Any help would be much appreciated!

This topic has been closed for replies.
Correct answer Bernd Alheit

Here is a link to the file. Thank you for your help!

Adobe Document Cloud


The field "CustomerName1" doesn't exist in the form.

1 reply

try67
Community Expert
Community Expert
November 14, 2018

Change the first line to:

if (event.target.value!="Off") {

And put the code as the Mouse Up event of the check-box field, and it should work (provided you entered the correct field names, of course).

D Heg
D HegAuthor
Participant
November 14, 2018

Thank you for the quick response!

I made the change and the code is under the Mouse Up event but I'm still not showing any results. Any other ideas?

try67
Community Expert
Community Expert
November 14, 2018

Check the JS Console (Ctrl+J) for error messages, and/or share the actual

file with us.