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

Combo Box Export Value numeric options

sagolf100
Registered: Oct 7 2009
Posts: 5

Hi,
I am new to this process so please hear me out and hopefully there is some easy method to do what I am trying to achieve.
I have a test combo-box field that has 3 items and an export value for each. A export as 01
B exports as 02, C - exports as 03. I have created another field that captures the export value, but it only captures 1, 2 or 3 and leave the preceding zero off because of it being a number. I have tried both single and double quote bookends on the export value, but it only gives me the single number. I also changed the value to 10, but then it gives me a 1 space 0. I really just want the value in the catching field to show exactly what I indicate in the export value.
 
Can I do something with the custom arbitrary mask on the receiving field or what other options do I have available?
 
Thanks for your review and help.

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Numbers usually do not have leading zeros, there is no point for it since 01 + 02 is 3 or 03. Numeric data is stored in a special number format and when this value is converted to display, leading zeros are not included. Numeric values with leading zeros are actually character strings.

Have you looked at the properties of the field object and the properties that relate to the "value" of a field?

There are the 'value' property and the 'valueAsString' property.

Beyond those two options, one can use the 'util.printd' method to display a numeric value with leading zeros or use the concatenation operator and the 'substr' method to add leading zeros to a numeric value.

George Kaiser

sagolf100
Registered: Oct 7 2009
Posts: 5
Thanks George, but the numeric value is a code and "01" has to be displayed as opposed to 1. I need to have the 2nd digit for this code, but I also don't want to have 010 show up because my code value is 10, but it is getting a leading zero that I don't want. Isn't there some way to force the export value to be just text and then it would show whatever I want to put there? In Excel for example, you can change the format of the cell to be text and it will show 0001 if that is what you want.

I'm not familiar with the 'util.printd' method you refer to. And where would I put the 'valueAsString' exactly? Is that on the combo box field or the receiving field and under which tab/box?

Thanks,
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
One needs to use the 'util.printf' method and not the 'util.printd' method. Sorry for the typo.

Observe what the following code does:

// variable for the field name
var cField = "Combo Box1";
// get the field object
var oValue = this.getField(cField);
console.show();
// show the value of the field
console.println("value = " + oValue.value);
// show the value of as the entered string
console.println("valueAsString = " + oValue.valueAsString);
// add leading zeros and substring the last 2 characters
var cLeadZero = "00" + oValue.value;
var cString = cLeadZero.substr(cLeadZero.length - 2, 2);
console.println("substr : " + cString);
// use the print format utility method to create a string with leading zeros
var uString = util.printf("%,102.0f", oValue.value);
console.println("util.printf: " + uString);

You will need to change the value of cField to the name of your combo box.


George Kaiser

sagolf100
Registered: Oct 7 2009
Posts: 5
Thanks George,
I found in another of your responses to users the command of:
event.value = this.getField('Box2').value;

I used this and at least my text export values are now coming over which were previously being ignored. So now I get XXX for my exported value in my receiving field. I placed that line in my custom calculation box on my "calculate" tab as you suggested to the other party and the text started coming.

I pasted in your statement, but immediately the debugger came up. I don't know how to debug or what to look for.
I'd really like to just have some command like this that accepts whatever I put in export and not assume it is numeric or some other value. I tried valueAsString but there must be more to this one since it had no effect. Probably something to do with adding event as in 'event.valueAsString' like the above or using parenthesis or some version of quotes. I'm not a programmer so not aware of those syntax requirements. I'll keep at it though and might have a fallback using an "O" instead of "0" for those first 9 digits as the export value.

Appreciate your help and if you have other suggestions, I'm ready for them...for next time I run into this.



try67
Expert
Registered: Oct 30 2008
Posts: 2398
If you'll paste here the contents of the error message in the debugger we would be able to help you solve it.
It could be something as simple as a missing quote, or something like that.

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

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Here is a working example along with the use of the "substring" method.

Zero Padding Example

George Kaiser