These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Auto Populate Bill to and Ship to fields

tsierra
Registered: Jul 24 2009
Posts: 43
Answered

Hello,

I'm working in Adobe Acrobat 8 and have created an order form.
I've created fields to enter the billing and shipping addresses.
Is there a way to create a check or radio box that will automatically copy over the shipping address to the billing address field so that the information need only be entered once if the ship to and bill to addresses are the same?

If they aren't the same, then the customer should also have the option to type in the information.

My Product Information:
Acrobat Pro 8.0, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You will want to use a check box so the box can be unchecked, radio buttons require a button to be checked after a selction and can not be unchecked.

For the check box you can use the following script with modifications to copy the necessary fields:
// check the state of the butotnif(this.getField(event.target.name).value == 'Yes') {// checked// copy address informationthis.getField('billing.address.street').value = this.getField('home.address.street').value;this.getField('billing.address.citystzip').value = this.getField('home.address.citystzip').value;// lock fieldsthis.getField('billing.address.street').readonly = true;this.getField('billing.address.citystzip').readonly = true;} else {// unchecked// unlock fieldsthis.getField('billing.address.street').readonly = false;this.getField('billing.address.citystzip').readonly = false}

George Kaiser

tsierra
Registered: Jul 24 2009
Posts: 43
Thanks for such a quick response! I will give this a shot and let you know how it goes.
tsierra
Registered: Jul 24 2009
Posts: 43
I'm not too familiar with Javascript. I've tried to figure it out on my own, with no luck. Should I replace your field names with mine? If so where?

My fields are as follows

shipaddress1
shipaddress2
shipcity
shipstate
shipzip
shipcountry

billaddress1
billaddress2
billcity
billstate
billzip
billcountry

Thanks again.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You need to change the quoted string within the "this.getField()" string and add lines as necessary for the number of fields.
// check the state of the buttonif(this.getField(event.target.name).value == 'Yes') {// checked// copy address information// get each billing field object's value and set the shipping field's valuethis.getField('shipaddress1').value = this.getField('billaddress1').value;this.getField('shipaddress2').value = this.getField('billaddress2').value;this.getField('shipcity').value = this.getField('billcity').value;this.getField('shipstate').value = this.getField('billstate').value;this.getField('shipzip').value = this.getField('billzip').value;this.getField('shipcountry').value = this.getField('billcountry').value;// lock fields// set each shipping field's read only property to locked - truethis.getField('shipaddress1').readonly = true;this.getField('shipaddress2').readonly = true;this.getField('shipcity').readonly = true;this.getField('shipstate').readonly = true;this.getField('shipzip').readonly = true;this.getField('shipcountry').readonly = true;} else {// unchecked// unlock fields// set each shipping field's readonly property to unlocked - falsethis.getField('shipaddress1').readonly = false;this.getField('shipaddress2').readonly = false;this.getField('shipcity').readonly = false;this.getField('shipstate').readonly = false;this.getField('shipzip').readonly = false;this.getField('shipcountry').readonly = false;}

George Kaiser

tsierra
Registered: Jul 24 2009
Posts: 43
This worked great, thanks!