• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Calculation resulting from checkbox selection in pdf

Explorer ,
Sep 23, 2017 Sep 23, 2017

Copy link to clipboard

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.

Many thanks in advance for help/advice.

TOPICS
PDF forms

Views

15.1K

Translate

Translate

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 guidelines

correct answers 1 Correct answer

Community Expert , Sep 23, 2017 Sep 23, 2017

Then use this:

event.value = 0;

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

else if (this.getField("fullpageadregular").value!="Off") event.value=700;

Votes

Translate

Translate
Participant ,
Dec 23, 2023 Dec 23, 2023

Copy link to clipboard

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

Votes

Translate

Translate

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

Copy link to clipboard

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.

Looking forward to your clarification.

Votes

Translate

Translate

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

Copy link to clipboard

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.

Votes

Translate

Translate

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

Copy link to clipboard

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.

 

Thanks in advance!

Votes

Translate

Translate

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

Copy link to clipboard

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;

Votes

Translate

Translate

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

Copy link to clipboard

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

Votes

Translate

Translate

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

Copy link to clipboard

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?

Votes

Translate

Translate

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

Copy link to clipboard

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

Votes

Translate

Translate

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

Copy link to clipboard

Copied

Is that the script you are using?

Votes

Translate

Translate

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

Copy link to clipboard

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.

Votes

Translate

Translate

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

Copy link to clipboard

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

Votes

Translate

Translate

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

Copy link to clipboard

Copied

Thanks

Votes

Translate

Translate

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

Copy link to clipboard

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("fullPageAd").value === "Yes") {
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("fullPageAd").setAction("MouseUp", updateTotal);
this.getField("exhibitor").setAction("MouseUp", updateTotal);

// Add more event listeners for other checkboxes as needed

Votes

Translate

Translate

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 guidelines