Skip to main content
Participant
August 5, 2022
Question

How do I create the calculation to subtract one text box from another?

  • August 5, 2022
  • 2 replies
  • 8553 views

I have a fillable pdf that I need to subtract 2 text boxes in order to get a remaining value.  ie: Text12 minus Text17.  Formula value would then populate Text18.

 

Thank you for your help,

Lee

2 replies

Participant
August 8, 2022

Thank you for the information.  I tried both the Simplified field notation (text12-text17) and (text12-text17=text18) and the custom calculation script coding and both ways give me the options to "cancel" or to "go to...." which then wants a "Line Number:"  I don't have a line number.  I tried 18, text18, & 7. (the number in the document that has the place for the answer)  Nothing seems to work.  When I click "ok", nothing happens.

 

Lee

try67
Community Expert
Community Expert
August 8, 2022

What are the EXACT names of the fields involved?

Participant
August 8, 2022

The names of the field are text12 and text17.  So - yest - I entered text12-text17 while in the text18 field, but then it wants to go to a line number.  How do I know what the Line # is?

ls_rbls
Community Expert
Community Expert
August 6, 2022

You may use built-in features, such as simplified notation in the field where you desired the event or action to take place; "Text18".

 

See the brief discussion in the link posted below: 

 

 

Or you may also employ a custom calculation script in the field "Text18".

 

var a = this.getField("Text12").value;

var b = this.getField("Text17").value;

if (a !=="" || b !=="") {

event.value = a-b;

} else {

event.value ="";

}

 

The custom script above is just one out of many examples that you can use to obtain the same result.

 

It may have errors and I haven't tested it on my end (typing from a mobile device).

try67
Community Expert
Community Expert
August 6, 2022

You might want to use && instead of || for this, as if one of the fields is empty the formula will treat it as zero, which is not always correct.

ls_rbls
Community Expert
Community Expert
August 6, 2022

Thank you!