• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Re: Calculating order form total column using Java...

# Calculating order form total column using Javascript

New Here ,
Jul 11, 2024 Jul 11, 2024

Copied

Hi

Apologies, I know nothing about Javascript.

I have an order form in Acrobat that I need to calculate a total with Goods and Services Tax (GST) attached image.

Staff members enter quantity (QTY) and unit price (UNITPRICE). They then choose Y or N to whether the unit price is inclusive of GST.

So, therefore the TOTAL column needs to calculate

If GST = Y

Then multiply QTY by UNITPRICE

Else multiply QTY by (UNITPRICE*1.1)

I know that I need to use javascript with a IF and THEN statements in the 'Custom Calculation Script' section, just not sure how to script it.

Thanks

Michael

TOPICS
JavaScript , PDF

Views

164

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Jul 11, 2024 Jul 11, 2024

Assume your check boxes are named "GST" (name them identically, but set the export values in the options tab to 1 for No and 1.1 for Yes.  At the top of the Total field calculation tab select Value is the product of and select the 3 fields.  The calculation will take the unchecked boxes as zero so it will calculate to zero until the user checks whether there is GST or not.  If you don't want a zero value when the GST boxes are not checked, use the following custom calculation script instead:

var

...

2 Replies 2
Community Expert ,
Jul 11, 2024 Jul 11, 2024

Copied

Assume your check boxes are named "GST" (name them identically, but set the export values in the options tab to 1 for No and 1.1 for Yes.  At the top of the Total field calculation tab select Value is the product of and select the 3 fields.  The calculation will take the unchecked boxes as zero so it will calculate to zero until the user checks whether there is GST or not.  If you don't want a zero value when the GST boxes are not checked, use the following custom calculation script instead:

var gst=1;

if(this.getField("GST").value!="Off")

{gst=this.getField("GST").value}

event.value=this.getField("QTY").value * this.getField("UNITPRICE").value*gst;

If you want to modify the script above once, so you don't have to modify for each Total field you can enter a script that antipates what the field names will be when you create all the rows from the first row using Right-click>Create multiple copies.  This article explains exactly how to do it, with video.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jul 11, 2024 Jul 11, 2024

Copied

LATEST

Thank you @PDF Automation Station, your help is much appreciated.

Have a great day!