Skip to main content
Participant
August 22, 2024
Question

Javascript Calculation multiply field and add previous

  • August 22, 2024
  • 1 reply
  • 300 views

Means: Acrobat PDF Fillable Form.

I want to make a TEXT FIELD called "Results" that takes a Value in another (seperate) TEXT FIELD, called "Amount" and multiplies that field it by "5" and then compounds/adds to all previous values... 


Example:
Amount is multiplied by 5 (1x5=5; 2x5=10; 3x5=15; 4x5=20, and so on)

Thus if "1" is in the field, the "Results" is 5, but if 2 is in the "Amount" field the "Results" would be 15 (5 + 10), and 3 would be 30 (5+10+15), and so on.

 

Anyone know how to code this?

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
August 22, 2024

Try something like this as 'Validate' script of "Amount" field:

if(!isNaN(event.value))
this.getField("Results").value += Number(event.value)*5;