Skip to main content
briannehadley
Inspiring
October 25, 2021
Resuelto

SOS / Java Script for Adobe Acrobat - Custom Script

  • October 25, 2021
  • 6 respuestas
  • 2336 visualizaciones

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. 

Este tema ha sido cerrado para respuestas.
Mejor respuesta de briannehadley

For anyone interested, attached is the working file. 

6 respuestas

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