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

field is not displaying product of two other fields within document.

New Here ,
Feb 13, 2017 Feb 13, 2017

I've created a service estimate document that contains fields that need to produce the multiplied product of two other. Unfortunately, the field does not display that product. Just still shows as 0.00

TOPICS
Acrobat SDK and JavaScript
619
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
Community Expert ,
Feb 13, 2017 Feb 13, 2017

We need a bit more information: How are you multiplying the two fields? There are at least three different methods to create calculation scripts, how are you doing this? Be as specific as possible? Are you getting an error message on the Javascript console? You can bring up the console via Ctrl-J or Cmd-J. What are the input fields? Are these text fields, or other field types? If they are text fields, what exactly do you enter?

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
New Here ,
Feb 13, 2017 Feb 13, 2017

Thanks Karl. I did a simple calculation in the properties screen: Screen Shot 2017-02-13 at 1.19.48 PM.png

All these are text fields and are formatted as Number with 2 decimal points. The inputs would be typically 1-4 or 5 for the qty field and the Text148 would be a dollar amount.

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
New Here ,
Feb 13, 2017 Feb 13, 2017

Karl, Please forgive my stupidity!!! I just noticed I incorrectly selected the wrong field for calculation. However, on another issue, how can I have a field not display anything if it is zero?

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
Community Expert ,
Feb 13, 2017 Feb 13, 2017

To suppress the result if it's zero, you will have to use a custom formatting script:

if (event.value == 0) {

    event.value = "";

}

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
New Here ,
Feb 13, 2017 Feb 13, 2017

So, if you'll indulge me, do I have to custom format the whole script?

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
Community Expert ,
Feb 13, 2017 Feb 13, 2017

No, just for the one field that you want to suppress the zero in. Bring up the field properties, then go to the "Format" tab and select "Custom". This will show two different custom scripts: The format script and the keystroke script. You want to use the above script as a custom format script:

2017-02-13_14-04-06.png

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
New Here ,
Feb 13, 2017 Feb 13, 2017

Karl, that worked perfectly!! Thank you so much for your help! By the way, on the fields with the zero suppression, is there a way to add code that shows 2 decimal points when a number populates?

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
Community Expert ,
Feb 13, 2017 Feb 13, 2017

Yes. Use the following instead:

if (event.value == 0) {

    event.value = "";

}

else {

    event.value = util.printf("%.2f", Number(event.value));

}

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
New Here ,
Feb 13, 2017 Feb 13, 2017
LATEST

Perfect! Thanks again. Have a great day!

Sent from my iPhone

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