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

Zero Drops in Zipcode when copying over values

Bob Casey
Registered: Aug 5 2009
Posts: 22
Answered

Hello

Hopefully you can help me out with this problem
I created a button that when clicked, will will populate the Shipping Information, if it is the same as the Billing Information.

My dilemma is that in when I populate the zipcode fields (which are special formatted for zipcode) with a zip's that begins with zero , I receive the following error: "the value enter does not match the format of the field [0.2.8-Ship to Zip]" (fyi both zipcode fields are formatted for zip)

When I remove the special zipcode formatting, the leading zero in the zipcode is dropped

Below is the javascript I am using.

//copy values if billing address is the same as shipping address
this.getField("0.2.4-Ship to Address 1").value = this.getField("0.1.5-Bill to Address 1").value;
this.getField("0.2.6-Ship tol Address 2 ").value = this.getField("0.1.4-Bill to Address 2").value;
this.getField("0.2.5-Ship to City ").value = this.getField("0.1.6-Bill to City").value;
this.getField("0.2.7-Ship to State ").value = this.getField("0.1.1-Bill to State").value;
this.getField("0.2.8-Ship to Zip").value = this.getField("0.1.8-Bill to Zip").value

Your help will be much appreicated.

My Product Information:
Acrobat Pro 8.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Try using 'valueAsString' instead of 'value'.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Bob Casey
Registered: Aug 5 2009
Posts: 22
Thanks try67

I know you put me on the right track. I am a newbie to javscript so please bear with me. I changed my java script to read valueAsString with no success. Please help me learn what i am doing wrong.

The code is below



// Acquire value from Right Field and apply value to Left Field
this.getField("0.2.4-Ship to Address 1").value = this.getField("0.1.5-Bill to Address 1").value;
this.getField("0.2.6-Ship tol Address 2 ").value = this.getField("0.1.4-Bill to Address 2").value;
this.getField("0.2.5-Ship to City ").value = this.getField("0.1.6-Bill to City").value;
this.getField("0.2.7-Ship to State ").value = this.getField("0.1.1-Bill to State").value;
this.getField("0.2.8-Ship to Zip").valueAsString = this.getField("0.1.8-Bill to Zip").valueAsString
Bob Casey
Registered: Aug 5 2009
Posts: 22
This works, but.....

this.getField("0.2.8-Ship to Zip").value = this.getField("0.1.8-Bill to Zip").valueAsString

I would like to undestand why when I use valueAsString=valueAsString does not work
this.getField("0.2.8-Ship to Zip").value = this.getField("0.1.8-Bill to Zip").valueAsString

Thanks for your input
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The reason is that valueAsString is a Read-Only property. You can't assign a value to it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Actually, in the JavaScript reference file under the valueAsString property, this exact situation is described (missing the leading zeros when accessing the value property).

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com