Skip to main content
briannehadley
Inspiring
Oct 25, 2021 11:29 PM UTC
Answered

SOS / Java Script for Adobe Acrobat - Custom Script

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 is closed to new replies. Start a new post to keep the conversation going.
briannehadley
briannehadleyCorrect answer
Inspiring
Oct 27, 2021 6:14 PM UTC

For anyone interested, attached is the working file. 

6 replies

briannehadley
Inspiring
Oct 27, 2021 6:07 PM UTC

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 

Translate
briannehadley
Inspiring
Oct 27, 2021 6:09 PM UTC

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

Translate
briannehadley
briannehadleyAuthorCorrect answer
Inspiring
Oct 27, 2021 6:14 PM UTC

For anyone interested, attached is the working file. 

Translate
briannehadley
Inspiring
Oct 25, 2021 11:32 PM UTC

Subtotal = "A"

Discount = "B"

Translate
Nesa Nurani
Community Expert
Community Expert
Oct 26, 2021 5:54 AM UTC

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);

Translate