Skip to main content
Inspiring
January 12, 2021
Answered

Auto populate an address field with the info also present in the adobe form

  • January 12, 2021
  • 1 reply
  • 2415 views

Hi! This is in connection with the question I posted earlier https://community.adobe.com/t5/acrobat/need-help-how-can-i-auto-populate-the-mailing-address-with-the-data-in-physical-address/m-p/11744581?page=1#M293206 where I also replied solved as my brother promised to help me do this one. But it turns out he doesn't know it also. 

 

Can anyone please help me or walk me through on how can I auto populate a mailing address (with city, state and zip) with the info found in the physical address (with city, state, zip) just by clicking a checkbox. Friends told me it is done by using java script. I'm new to adobe and have no idea how to do Java script. Please help!

 

The text fields are:

 

Physical Address:_______________________    City: _______________

State: ________________________________  Zip: ________________

 

Mailing Address: ______________________      City: _______________

State: _______________________________     Zip: ________________

 

I've tried using this script below but it only copies one text field, the physical address only. I don't know how to include the city, zip, and state.

 

//Set the vars one and two:
var one = this.getField("pstreet");
var two = this.getField("mstreet");

//next check if two is blank and if so, populate it with one’s value
if(two.value==''||two.value==null){two.value=one.value}

 

Thank you very much!

This topic has been closed for replies.
Correct answer try67

@try67 this is what I did:

 

this.getField("mstreet").value=this.getField("pstreet").value;
this.getField("mcity").value=this.getField("pcity").value;
this.getField("mstate").value=this.getField("pstate").value;
this.getField("mzip").value=this.getField("pzip").value;

 

I think it worked fine for me. I just can't reset the mailing address field when i clicked again the checkbox to remove the check.


You can use something like this:

 

if (event.target.value=="Off") {
	this.resetForm(["mstreet", "mcity", "mstate", "mzip"]);
} else {
	this.getField("mstreet").value=this.getField("pstreet").value;
	this.getField("mcity").value=this.getField("pcity").value;
	this.getField("mstate").value=this.getField("pstate").value;
	this.getField("mzip").value=this.getField("pzip").value;
}

 

 

1 reply

km011221Author
Inspiring
January 12, 2021

Used the solution found here https://community.adobe.com/t5/acrobat/auto-populate-physical-to-postal-address-with-a-check-box-acrobat-pro-dc/m-p/10966934?page=1 and works fine with me. Just need to do some edits on it. 

Thank you to all who answered the post where I found the solution to my problem. 

try67
Community Expert
Community Expert
January 12, 2021

Yes, follow the advice in that thread. Duplicate the lines of code for each field you want to copy, adjusting the field names in it, of course.

km011221Author
Inspiring
January 12, 2021

@try67 this is what I did:

 

this.getField("mstreet").value=this.getField("pstreet").value;
this.getField("mcity").value=this.getField("pcity").value;
this.getField("mstate").value=this.getField("pstate").value;
this.getField("mzip").value=this.getField("pzip").value;

 

I think it worked fine for me. I just can't reset the mailing address field when i clicked again the checkbox to remove the check.