• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• Calculation resulting from checkbox selection in p...

Calculation resulting from checkbox selection in pdf

Explorer ,
Sep 23, 2017 Sep 23, 2017

Copied

I'm probably way out of my league here, but here's what I need to happen:

I have a fillable pdf with several checkboxes that would result in an amount being added to a total field (Ex: Full page ad / Exhibitor fee is \$500 / Non exhibitor fee is \$750), so the user selects two items (or none). If they check "Full page ad" checkbox, then they select whether or not they are an exhibitor, then the amount (\$500) would go to the total field = \$500. And several more optional add choices, etc.

So, I guess my question(s) are:

If a checkbox is selected, can a number populate in a separate field? And if so, how?

I am a javascript beginner, have only completed the calculations that were simple.

TOPICS
PDF forms

Views

14.8K

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 , Sep 23, 2017 Sep 23, 2017

Then use this:

event.value = 0;

if (this.getField("fullpageexhibitor").value!="Off") event.value=500;

37 Replies 37
Participant ,
Dec 23, 2023 Dec 23, 2023

Copied

There's a much easier way.  Create one check box ("CheckBox") then use right-click > Create Create Multiple Copies to create the rest of the fields (named "CheckBox.0" through "CheckBox.10").  Set the export values to the dollar amounts for each box.  In the Subtotal field, calculation tab, use "Value is the sum of" and select the field "CheckBox".  Done.  Here's a step by step guide with video:

https://pdfautomationstation.substack.com/p/create-a-check-box-scoring-questionnaire

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

hank you for your inquiry. To provide you with the accurate export values of the checkbox fields, we would need more specific details about the checkboxes in question. Each checkbox can be customized to have its own export value based on the requirements of the form or system you are using.

Please provide the names or descriptions of the checkbox fields you are referring to, and any additional context that might help us assist you better. Once we have more information, we will be able to furnish you with the precise export values for the specified checkboxes.

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

LATEST

I resolved it by making hidden fields and using a script someone else gave me earlier. But I will look at this one and see if it fits better for the long run.

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 ,
Sep 21, 2019 Sep 21, 2019

Copied

Hi there

I've been searching the community and this thread is the closest I found regarding what I'm trying to achieve. I am very rusty with my script knowledge as I haven't practiced it for years; I'm practically beginner level at this point. I have a similar situation where I have a list of services (with checkboxes) that have the same pricing; however, I do want multiple selections added up to a total.

The form allows the client to choose from 3 Service Package deals (Packages 1 to 3). Currently I have these as radio buttons where they can only select one. For the sake of math I'll keep the pricing simple: Packages 1 to 3 are \$5000, \$3000, and \$1000 respectively. Each service package offers discounts on additional services. Package1 offers \$1000 discount, Package2 \$500, and Package3 no discount. The group of radio buttons is named "Group1" and their button choices are 1, 2, & 3 respectively.

There are 5 additional services, Services A to E. The client filling up the form can choose to select as many services, including none. Each service costs \$500. However, depending on the Package deal they selected earlier in the form (Packages 1 to 3), they get 2 (\$1000) or 1 (\$500) services discounted. I would like to autofill the text field named "TotalExtras" so the client would instantly know how much extra on top of the base Package they have chosen.

First Example:

Client selects Package2 for \$3000 (which will discount \$500 from total extras). The client continues to next section and selects three additional services, say A, B & D. So the three choices should total \$1500 (\$500 each). But because they have chosen Package2, the autofill total in the TotalExtras text field should read "\$1000" (\$1500 additional services minus \$500 Package2 discount).

Second Example:

Client selects Package1 for \$5000 (which will discount \$1000 from total extras). The client continues to next section and selects only one additional service, they choose C. The single choice should total \$500. But because they have chosen Package1, the autofill total in the TotalExtras text field should read "\$0" (\$500 additional services minus \$1000 Package1 discount). The total for this TotalExtras field should never be negative and there is no option to go lower than the base price of the chosen Package.

Is this posssible? Or am I asking for too much? Also, am I supposed to have all the checkboxes under one name? They all currently have separate names.

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 ,
Jun 07, 2020 Jun 07, 2020

Copied

I have a similar issue... this is the code im trying to use, Im trying to get a check box in adobe to (When checked) to subtract "TTLCalculated" And use that value in the next part of my code, wanted to know if what im doing wrong, im a newbie to javascript, would really appreciate the help!

var DA = Number(this.getField("Downpayment*").valueAsString);

var DA2 = Number(this.getField("TTLCalculated").valueAsString);

event.value = (DA-DA2);

if (this.getField("TTLCalculated").value!="Off") event.value=(DA-DA2);

else if (this.getField("TTLCalculated").value!="Off") event.value=0;

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 ,
Jun 08, 2020 Jun 08, 2020

Copied

YOu have exactly the same condition in both parts of the if block. Remove the second if. Just use an else.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 20, 2021 Jan 20, 2021

Copied

Hello,

I am trying to do something similar. I have a specific rate that gets calculated on top of the total amount. However, the payment type changes the rate.

At the moment All payment types has a rate of 8.42% added to the total amount which is annotated in the G&A (named 5 on the PDF) i have added using the simplified filed notation which is TOTAL_COST * 0.0842, this will happen regardless the payment type. However, for three payment types its 7.67% added cost and one is 9.55% added cost. How do I have the specific rate calculation work with the specific payment type selected?

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

I am trying to do something similar but I think I am missing something.

Mine seems like it would be basic.

Text 1 = Text 2 +(5 if Checkbox 1 is checked) + (5 if Checkbox 2 is checked) + Text 3 + Text 4

Report

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

Copied

Is that the script you are using?

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

No, that is the end result I want to create. I am very new to editing Adobe but want to start making more use of this program I am paying for.

Report

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

Copied

Set the export values of Checkbox 1 and Checkbox 2 to 5.  In the calculation tab of Text 1, select Value is the sum of, then select the following fields:  Text 2, Checkbox 1, Checkbox 2, Text 3, and Text 4.  This might help you learn how this works:

https://pdfautomationstation.substack.com/p/create-a-check-box-scoring-questionnaire

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

Thanks

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 Beginner ,
Dec 23, 2023 Dec 23, 2023

Copied

// Add this script to the "Custom Calculation Script" of the total field

var total = 0;

// Function to update total based on checkbox selections
function updateTotal() {
total = 0;

// Check each checkbox and update total accordingly
if (this.getField("exhibitor").value === "Yes") {
total += 500; // Full page ad exhibitor fee
} else {
total += 750; // Full page ad non-exhibitor fee
}
}

// Add more conditions for other checkboxes if needed

// Update the total field
this.getField("totalField").value = total;
}

// Set up event listeners for each checkbox
this.getField("exhibitor").setAction("MouseUp", updateTotal);

// Add more event listeners for other checkboxes as needed