Skip to main content
Participating Frequently
Apr 11, 2018 9:54 PM UTC
Answered

Custom Calculation on a form

I am trying to write a custom calculation that adds 3 percent to a specified total when over 500 dollars if a credit card number appears in a field at the bottom of the form

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Apr 13, 2018 8:33 PM UTC

here is the scenario

total before freight

freight

total with freight

grand total

The grand total should be the total with a 3% up charge if the credit card field at the bottom of the form is complete

if not complete then should display same as total w freight


OK. Let's say the name of the CC field is "CC". In that case, use this code as the custom calculation script of "Grand total".

var total = Number(this.getField("total with freight").valueAsString);

if (this.getField("CC").valueAsString=="") event.value = total;

else event.value = total * 1.03;

10 replies

try67
Community Expert
Community Expert
Apr 13, 2018 3:58 PM UTC

Is this a PDF form, created in Acrobat?

Translate
Participating Frequently
Apr 13, 2018 4:59 PM UTC

yes, this is a pdf form created in Acrobat

Translate
try67
Community Expert
Community Expert
Apr 13, 2018 5:12 PM UTC

OK, I'm going to move your question to a more relevant forum: JavaScript

Can you describe the exact conditions in which you want this calculation to take place?

Is it when the value of one field is more than 500, AND a different field (the CC number) is not empty?

Translate