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

Calculating an editable sum in Acrobat Pro DC

New Here ,
Jul 08, 2018 Jul 08, 2018

Copy link to clipboard

Copied

Hi guys,

I currently have a fillable PDF with a field called 'Total Chargeable Amount'. This is calculated by the sum of 10 other fields, which are all named 'A_1' up to 'A_10'.

This works fine using the built in calculation function, but I want the amount to be editable once it has been populated. I believe I need Javascript to make that possible.

Can anyone tell me what I should put in the 'Custom calculation script' field to do this?

Thanks!

Tom

TOPICS
Acrobat SDK and JavaScript , Windows

Views

883

Translate

Translate

Report

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 , Jul 09, 2018 Jul 09, 2018

HI,

There is but it would be a lot of work, as you would have to try and work out when a value is to be calculated, and then if the total field is edited, stop the calculation, but what if something in one of the calculated fields is changed, do we then run the calculation again, and then the user would have to enter the discount again, and then we have to stop the calculation again, and so on and so on.

It would be tricky to get this right, a much easier option is the one mentioned by try67​ whic

...

Votes

Translate

Translate
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

HI,

I am not sure what you are trying to achieve, the field can be editable that is not a problem, but if we run a 'custom calculation script', this will run every time a field is exited, included the total field. This would mean that the user would edit the field, and then click or tab to another field, the calculations would run and then whatever they typed in would be overwritten.

I am sure this is not what you want to happen.

Regards

Malcolm

Votes

Translate

Translate

Report

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 ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

Hi Malcolm.

Essentially, the Total Chargeable Amount may be less than the amount that is automatically calculated if a discount has been applied.

The changes that are made at the moment are overwritten as soon as you click away from the Total field, as you described.

Is there a way to prevent this from happening?

Tom

Votes

Translate

Translate

Report

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 ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

I would recommend you create a separate field for the discount amount, and then include its value in the calculation of the total.

Votes

Translate

Translate

Report

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 ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

Thanks try67. This is the fall back. The issue is we don’t want to ‘promote‘ discounts, if that makes sense.

Is there no way through applying code to do this?

Votes

Translate

Translate

Report

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 ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

LATEST

HI,

There is but it would be a lot of work, as you would have to try and work out when a value is to be calculated, and then if the total field is edited, stop the calculation, but what if something in one of the calculated fields is changed, do we then run the calculation again, and then the user would have to enter the discount again, and then we have to stop the calculation again, and so on and so on.

It would be tricky to get this right, a much easier option is the one mentioned by try67​ which is to have a field that would be included in the sum to introduce the discount, although there is no need to call it "discount' you woundn't even have to name it you could just have a blank empty field, which is a discount when it has a value of nothing when it doesn't.

Regards

Malcolm

Votes

Translate

Translate

Report

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