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.
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;
Copy link to clipboard
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;
Copy link to clipboard
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?
Copy link to clipboard
Copied
I tried using this:
event.value = (this.getField("fullpageexhibitor").value=="Off") ? 0 : 500;
event.value = (this.getField("fullpageadregular").value=="Off") ? 0 : 700;
Copy link to clipboard
Copied
No, that won't work... What if both boxes are ticked?
Copy link to clipboard
Copied
They can only choose one box (either 500 or 700)
Copy link to clipboard
Copied
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;
Copy link to clipboard
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
Copy link to clipboard
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.
Copy link to clipboard
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?
Copy link to clipboard
Copied
Yes, but this is getting more complicated...
On Sat, Sep 23, 2017 at 9:59 PM, sasegars58 <forums_noreply@adobe.com>
Copy link to clipboard
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.
Copy link to clipboard
Copied
I have several boxes and they can check more than 1, how do I sum up the value of their choices? Thanks.
Copy link to clipboard
Copied
Please post a more detailed explanation to a new thread.
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:
https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm
Copy link to clipboard
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.
Copy link to clipboard
Copied
Copy link to clipboard
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?
Copy link to clipboard
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?
Copy link to clipboard
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?
Copy link to clipboard
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
Approvers
Building Security Group
Approvers
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
Copy link to clipboard
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.
Copy link to clipboard
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.
Copy link to clipboard
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.
Copy link to clipboard
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:
Copy link to clipboard
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":"";