Copy link to clipboard
Copied
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
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;
Copy link to clipboard
Copied
Is this a PDF form, created in Acrobat?
Copy link to clipboard
Copied
yes, this is a pdf form created in Acrobat
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Correct
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Thank you.
var total with all = Number(this.getField("total with freight").valueAsString);
if (this.getField("Card#").valueAsString=="") event.value = total with all;
else event.value = total with all * 1.03;
I got a syntax error: ; missing before statement 1 at line 2
Copy link to clipboard
Copied
You can't include spaces in the name of a variable.
On 13 April 2018 at 23:55, charlenen64197186 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
You did not copy the provided code as provided.
Variable names cannot contain spaces.
Copy link to clipboard
Copied
I copied it, but attempted to use the correct names for the fields and put in spaces. Not a problem thank you.
I will try on Monday. leaving for the day.
I appreciate the help