Copy link to clipboard
Copied
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!
The field "CustomerName1" doesn't exist in the form.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Check the JS Console (Ctrl+J) for error messages, and/or share the actual
file with us.
Copy link to clipboard
Copied
Here is a link to the file. Thank you for your help!
Copy link to clipboard
Copied
The field "CustomerName1" doesn't exist in the form.
Copy link to clipboard
Copied
Wow! I had a space between customer and name and couldn't tell. Thank you all for your help it's working now!.