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

Subtracting two fields that are total fields

New Here ,
Apr 09, 2020 Apr 09, 2020

I am trying to subtract two fields, the fields I am attempting to subtract are "totalled" fields, meaning that field's total has a calculation.  I need to subtract "totalasset" from "totalliabilities" giving me the answer in my "networth" field.  However, no matter what I try I cannot get the two fields to subtract. Can someone please help me?  I have use the following formula in create  and edit Javascripts:

 

//compute the difference of the estimated value less the actual value
event.value = this.getField("TOTALASSETS").value - this.getField("TOTALLIABILITIES").value;

 

Help please, I have spent so much time trying to figure this out and I need to complete this pdf form.

 

Thank you in advance,

Marie

TOPICS
How to
2.5K
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Apr 09, 2020 Apr 09, 2020

You probably have a JS error you don't know about, but since this calculation does not need JavaScript, use simplified field notation. 

See the example file here:

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

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 ,
Apr 09, 2020 Apr 09, 2020

BTW: the error is in the field names. There's a space. Get Rid of it and it'll all work.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

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 ,
Apr 09, 2020 Apr 09, 2020

You probably have a JS error you don't know about, but since this calculation does not need JavaScript, use simplified field notation. 

See the example file here:

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Apr 09, 2020 Apr 09, 2020

BTW: the error is in the field names. There's a space. Get Rid of it and it'll all work.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Apr 09, 2020 Apr 09, 2020
LATEST

Thank you so much @Thom_Parker you were a great help!

I am VERY grateful.

Best, Marie

Stay Safe. Stay Well. 

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