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

Convert postal/zip code number to text to keep leading zeros

vwilliams
Registered: Feb 6 2008
Posts: 35
Answered

Hi. I got a little help w/ this a while back. I finally started to use the code/form and noticed the leading zero was being dropped from the postal code. Is there any way I can convert the number to a text so that doesn't happen? I tried a few things that I found on this site and others but none seem to work. This will need to work for Adobe Acrobat vers 6 and up.

Thanks!

// Concatenate Investigator Postal Address, i.e. City, State and Zip
// Custom calculation script for "Investigator.PostalAdd"
// Get field references
// Written w/ the help of gkaiseril from the Acrobat User Community Group

var cCITY = this.getField("Investigator.CITY").value;
var oSTATE = this.getField("Investigator.STATEID.STATELIST");
var cZIP = this.getField("Investigator.ZIP").value;
var xPostalAdd = this.getField("Investigator.PostalAdd");

// get combo box state item name
var cSTATEitemName = ""; // clear field

// loop through combo box for match to export value to item in combo box list
for (i = 0; i < oSTATE.numItems; i++)
{ if(oSTATE.getItemAt(i, true) == oSTATE.value)
{
cSTATEitemName = oSTATE.getItemAt(i, false); // get item name
break; // end loop on match
} // end if match
} // end for loop

xPostalAdd.value = ""; // clear field

// fillin if all fields have a value

if ((cCITY != "") || (cSTATEitemName != "") || (cZIP != ""))
{
// Set this field value by concatenating the other fields
xPostalAdd.value = cCITY + ", " + cSTATEitemName + " " + cZIP;
}

My Product Information:
Acrobat Pro 6.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Did you try using valueAsString instead of value?
See the discussion here: http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=21311

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

vwilliams
Registered: Feb 6 2008
Posts: 35
Try67 that worked! I didn't know about the valueAsString option and didn't find it while searching the forums. Actually I had a lot of problems on this site yesterday, e.g. links weren't working.

Anyway... Thanks for the help!
try67
Expert
Registered: Oct 30 2008
Posts: 2399
You need to use the Acrobat JavaScript Scripting Reference. It contains all of this information.
Especially the Field object is of importance for your purposes.

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

vwilliams
Registered: Feb 6 2008
Posts: 35
Thanks Try67!!! Non of the books I have helped at all but they were JS only books not Acrobat specific.

Have a great day!