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

# 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

15.9K

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;

72 Replies 72
Community Expert ,
Sep 23, 2017 Sep 23, 2017

Copied

Yes, that's easily done. For example, let's say you have a check-box called "Checkbox1" and you want to populate a field called "Text1" with 500 if it's checked, and zero otherwise.

Use this code as the custom calculation script of Text1:

event.value = (this.getField("Checkbox1").value=="Off") ? 0 : 500;

Report

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

Copied

WOW! Thank you @try67â€” may I ask how to complete it if there are two choices? So if one box is checked, it's 500, and if the other box is checked it's 700?

Report

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

Copied

I tried using this:

event.value = (this.getField("fullpageexhibitor").value=="Off") ? 0 : 500;

event.value = (this.getField("fullpageadregular").value=="Off") ? 0 : 700;

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

Copied

No, that won't work... What if both boxes are ticked?

Report

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

Copied

They can only choose one box (either 500 or 700)

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

Copied

Then use this:

event.value = 0;

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

Report

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

Copied

YES!!!! You're a genius and a scholar and my hero!!!!!!! Thank you try67â€‹ !!!!!

May I ask for another scenario? They also have an input field where they can enter certain booth numbers that are premium prices, so if they enter 301, the price is \$1,000, if they enter 302 the price is \$1,200 -- how would you do that or can that be done? In this case, the user enters a specific number

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

Copied

You can use something like this:

if (this.getField("boothnumber").valueAsString=="301") event.value=1000;

if (this.getField("boothnumber").valueAsString=="302") event.value=1200;

etc.

Report

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

Copied

You're my BEST FRIEND! Thank you try67â€‹!!! That worked, BUT the user can actually enter more than one booth number (maximum 3) in that one field (separated by a comma) -- is it possible to add the amounts?

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

Copied

Yes, but this is getting more complicated...

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

Copied

If you wish I can create this script for you, for a small fee. You can send me the full specs to try6767 at gmail.com and we could discuss the details.

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 ,
Feb 16, 2022 Feb 16, 2022

Copied

I have several boxes and they can check more than 1, how do I sum up the value of their choices? 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 Expert ,
Feb 17, 2022 Feb 17, 2022

Copied

There are many different ways to add-up checkbox selections. The exact solution depends on the exact details.

Also, you might start by learning a bit more about scripting PDF checkboxes:

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 ,
Feb 17, 2022 Feb 17, 2022

Copied

Thanks, I created radio checkboxes (for options where they can only choose 1) and regular checkboxes and assigned different values for each checkbox. I was then able to sum up the values based on their choices.

Report

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

Copied

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 18, 2022 Jul 18, 2022

Copied

Thanks for this, I just have one question, what do i put in when it says "Line Number"? I tried Textbox29 which is where the total will go, nothing happens

Also I need to total a number of text boxes, is this possible?

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 13, 2024 Jun 13, 2024

Copied

Hi! I was hoping you could help me with a code. I want to have a summary area that lists the checkboxes that were ticked.

Department name

Checkbox - Will you need graphics?

Checkbox - Minnie Mouse

Checkbox - Daffy Duck

If they check the question and the names, I want it to appear in a summary.

Could you please give me the steps and code to do this?

Report

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

Copied

Are your checkboxes a series (same name, different export values), or different checkboxes?  What do you want in the list - the names of the checkboxes fields or the export values?

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 13, 2024 Jun 13, 2024

Copied

The check boxed are different and they need to check all that apply. The checkboxes are grouped by Department, so it would help to have them grouped in the summary too.

Here is an example of my form (the bullets are checkboxes)

For each group, select a question if the answer is Yes. Then, select the relevant country/approvers.

Party Planning Group

• Do you need tables?
• Do you need a microphone

Approvers

• US - Minnie Mouse
• UK - Mickey Mouse

Building Security Group

• Will you have outside visitors?
• Will you need parking passes?

Approvers

• US - Daffy Duck
• Asia - Roger Rabbit

SUMMARY

Based on your responses, here is a list of who you will need to contact:

Party Planning

US - Minnie Mouse

UK - Minnie Mouse

Security

Asia - Roger Rabbit

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 13, 2024 Jun 13, 2024

Copied

Sorry! I also need the questions to appear in the summary. So...

SUMMARY

Here is a summary of your selections:

Party Planning

Do you need tables?

Do you need a microphone?

Approvers

US - Minnie Mouse

UK - Minnie Mouse

When I name the checkboxes, I'll add a "Yes-" before the question.

Report

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

Copied

The "approvers" check boxes should have the approver as the export values.  Create a Summary text field with mult-line checked in the options tab then enter the following custom calculation script:

``````event.value=
"SUMMARY\r"+
"Here is a summary of your selections:\r\r"+

"Party Planning"+
"Do you need tables?" + this.getField("Tables").value.replace("Off","No") +"\r"+
"Do you need a microphone?" + this.getField("Microphone").value.replace("Off","No") +"\r\r"+

"Approvers\r"+
this.getField("Approver1").value!="Off"?this.getField("Approver1").value+"\r":""+
this.getField("Approver2").value!="Off"?this.getField("Approver2").value+"\r":""+``````

The script above should get you started.  The "\r" are new lines.  Replace the last + with ; when you are done.

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 13, 2024 Jun 13, 2024

Copied

Thank you! Okay, so I got it to populate, but it's listing the questions and adding Yes or No to the end. I only need it to list the questions that have the text box ticked. Also, I can't get it to put a line space between each line.

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 13, 2024 Jun 13, 2024

Copied

I edited the code a little and I got it to show only the Group name and value I entered for the questions check box, which is good.

The only issues now are:

• There are no line spaces
• The list of reviewers won't populate when I tick the box.
• If I don't click a question check box, it populates as No. I'd like for it to not populate anything.

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 13, 2024 Jun 13, 2024

Copied

Here is the code I have now:

event.value=

"Client Services"+

this.getField("ClientServicesQ1").value.replace("Off","No") +"\r"+

this.getField("ClientServicesQ2").value.replace("Off","No") +"\r\r";

"Reviewers\r"+

this.getField("CSReviewer1of5").value!="Off"?this.getField("CSReviewer1of5").value+"\r":""+

this.getField("CSReviewer2of5").value!="Off"?this.getField("CSReviewer2of5").value+"\r":""+

this.getField("CSReviewer3of5").value!="Off"?this.getField("CSReviewer3of5").value+"\r":""+

this.getField("CSReviewer4of5").value!="Off"?this.getField("CSReviewer4of5").value+"\r":""+

this.getField("CSReviewer5of5").value!="Off"?this.getField("CSReviewer5of5").value+"\r":"";