Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trailing zeros dropped from field when using barcode

New Here ,
Jan 26, 2017 Jan 26, 2017

I have a form that has a text field for a percentage (5 digits with decimal).  If the percent is 100.00, the barcode reads 100.  Is there a way to capture the percentage without the decimal and keep the trailing zeros in the barcode?

Here is what I have tried:

strValues += oParam.oDoc.getField(strFieldName).value.toString().replace(/\./g'');

with results of 100.

Thanks

TOPICS
Acrobat SDK and JavaScript , Windows
654
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 26, 2017 Jan 26, 2017

Instead of the value property use the valueAsString property of the field object.

Translate
Community Expert ,
Jan 26, 2017 Jan 26, 2017

Instead of the value property use the valueAsString property of the field object.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 27, 2017 Jan 27, 2017
LATEST

So, you want to display the number in "hundredths of percents".

The easiest way would be to multiply the field's value with 100. If you need the preceeding zeroes, you would use the util.printf() method to format the number with preceding zeroes. You may also need the Math.floor() method to cut off remaining decimal digits. And that should do it.

Also, in my understanding of the replace() method, you'd have to separate the Regular Expression and the replacement string with a comma.

And, in this situation it is better to use the valueAsString property, as already mentioned by Karl Heinz Kremer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines