Skip to main content
briannehadley
Inspiring
October 25, 2021
Answered

SOS / Java Script for Adobe Acrobat - Custom Script

  • October 25, 2021
  • 2 replies
  • 2319 views

Hi there! 
Am trying to use the "Custom Calculation Script" to calculate a percentage off a final sale for the "Amount Due" field. For example, if the total is $100 and I grant 25% off, I want the Amount Due to show as that. 

This topic has been closed for replies.
Correct answer briannehadley

For anyone interested, attached is the working file. 

2 replies

briannehadley
Inspiring
October 27, 2021

I was able to figure it out! Very simple solution actually.
For anyone interested, the equation I used was this: 

 

event.value = this.getField ("A").value - ( this.getField("A").value * this.getField("B").value )

 

whereas

A = Subtotal

B = Discount Amount 

briannehadley
Inspiring
October 27, 2021

event.value = this.getField ("A").value - ( this.getField("A").value * this.getField("B").value )

briannehadley
briannehadleyAuthorCorrect answer
Inspiring
October 27, 2021

For anyone interested, attached is the working file. 

briannehadley
Inspiring
October 25, 2021

Subtotal = "A"

Discount = "B"

Nesa Nurani
Community Expert
Community Expert
October 26, 2021

Try this:

var s = Number(this.getField("A").value);
var p = Number(this.getField("B").value);
if(p == 0)
event.value = s;
else
event.value = s*(1-p);