Skip to main content
New Participant
December 13, 2018
Answered

Javascript for dividing one field and answering into another field

  • December 13, 2018
  • 2 replies
  • 4198 views

I have Adobe Acrobat DC - and I have a fillable PDF with Columns.

I am attempting to divide one field (TOTAL ROW 1) by 2 to answer in the column field beside it COOP AMOUNT x 50Row1.

I tried multiplication and that didn't seem to work either. I can easily change the name of the field

I supplied a small portion of the form below.

THank you so much, as I have been trying everything

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

So you want the field "COOP AMOUNT x 50Row1" to be ("TOTAL ROW 1"/2) ?

These names will cause the "Simplified Notation" calculation to fail.  The field names cannot contain spaces or punctuation.

But this could be done with JavaScript without changing the field names.

For example:

event.value = this.getField("TOTAL ROW 1").value/2;

You could even create a generic document function to perform the calculation. 

Read more about scripting calculations here:Calculating field values and more

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

2 replies

New Participant
December 13, 2018

Thank you so much Thom!! THAT WORKED!!

Thom Parker
Thom ParkerCorrect answer
Community Expert
December 13, 2018

So you want the field "COOP AMOUNT x 50Row1" to be ("TOTAL ROW 1"/2) ?

These names will cause the "Simplified Notation" calculation to fail.  The field names cannot contain spaces or punctuation.

But this could be done with JavaScript without changing the field names.

For example:

event.value = this.getField("TOTAL ROW 1").value/2;

You could even create a generic document function to perform the calculation. 

Read more about scripting calculations here:Calculating field values and more

and 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