Skip to main content
Participant
April 9, 2020
Answered

Subtracting two fields that are total fields

  • April 9, 2020
  • 1 reply
  • 2384 views

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

This topic has been closed for replies.
Correct answer Thom Parker

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

1 reply

Thom Parker
Community Expert
Community Expert
April 9, 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 9, 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 PDFScriptingUse the Acrobat JavaScript Reference early and often