• 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

18.6K

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

Copy link to clipboard

Copied

Okay, it's working now! Below is the code. If I don't select a box, it lists No. What do I change ("Off","No") to to get rid of that?

 

event.value=

"Client Services\r"+

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

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

 

"Reviewers\r"+

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

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

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

 

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

 

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

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

Copy link to clipboard

Copied

Change:

replace("Off","No")

To:

replace("Off","")

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

Copy link to clipboard

Copied

Okay, that worked, but it's like the space is still reserved. So if I selected only the 5th check box there are give blank line spaces in the summary area. Is there a code that just lists them as they are checked but without a replace command?

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

Copy link to clipboard

Copied

I have already written the code for you previously in this thread:

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

etc.

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

Copy link to clipboard

Copied

That one isn't working. The one Try67 gave me is working but I just need it to stop listing No when the checkbox isn't selected. Even when I delete No and use " ", the blank line is there like it's still recognizing the line. I want it to just shift the next item up if nothing is selected.

 

event.value=

"Client Services\r"+

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

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

"Reviewers\r"+

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

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

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

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

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

 

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

Copy link to clipboard

Copied

Successfully tested:

var line1=this.getField("ClientServicesQ1").value!="Off"?this.getField("ClientServicesQ1").value+"\r":"";
var line2=this.getField("ClientServicesQ2").value!="Off"?this.getField("ClientServicesQ2").value+"\r":""; 
var line3=this.getField("CSReviewer1of5").value!="Off"?this.getField("CSReviewer1of5").value+"\r":""; 
var line4=this.getField("CSReviewer2of5").value!="Off"?this.getField("CSReviewer2of5").value+"\r":""; 
var line5=this.getField("CSReviewer3of5").value!="Off"?this.getField("CSReviewer3of5").value+"\r":""; 
var line6=this.getField("CSReviewer4of5").value!="Off"?this.getField("CSReviewer4of5").value+"\r":"";
var line7=this.getField("CSReviewer5of5").value!="Off"?this.getField("CSReviewer5of5").value+"\r":"";
event.value=
"Client Services\r"+line1+line2+"Reviewers\r"+line3+line4+line5+line6+line7;

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

Copy link to clipboard

Copied

thank you! That works perfectly. I need to do 12 more. When I start with the next one on the next line it breaks. Is there anything I need to add between the two?

 

 

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

Copy link to clipboard

Copied

Are you saying your code breaks, or want the line to break?

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

Copy link to clipboard

Copied

It breaks when I paste this below it:

 

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

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

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

event.value=

"Development\r"+line1+"Reviewers\r"+line2+line3;

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

Copy link to clipboard

Copied

Post the full code, and explain what you mean by "it breaks"... What exactly happens?

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

Copy link to clipboard

Copied

Okay, the first code you gave me worked. It listed:

Client Services

Q1 Value (the question I want it to show)

Reviewers

Reviewers names

 

Then when I added on the next one (Development) and I check the boxes for both Client Services and Devlopment, only Development shows (it does listed everything correctly). If I only click the boxes for Client Services, it only shows the label. Here is the full code:

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

event.value=

 

"Client Services\r"+line1+line2+"Reviewers\r"+line3+line4+line5+line6+line7;

 

 

 

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

 

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

 

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

 

event.value=

 

"Development\r"+line8+"Reviewers\r"+line9+line10;

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

Copy link to clipboard

Copied

Also, that last message is old - I replied to the notification email and I guess there is a lag. The latest message is the one above it - me telling you what I mean by broken and giving th3 full code.

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

Copy link to clipboard

Copied

event.value is one value for the entire field, so if you have it twice the 2nd will overwrite the first.

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

Copy link to clipboard

Copied

Thanks! The below code works. Now how do I get an line space before each group label (before Development).

 

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

event.value=

 

"Client Services\r"+line1+line2+"Reviewers\r"+line3+line4+line5+line6+line7+"Development\r"+line8+"Reviewers\r"+line9+line10;

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

Copy link to clipboard

Copied

It breaks when I paste this below it:

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

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

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

event.value=

"Development\r"+line1+"Reviewers\r"+line2+line3;

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

Copy link to clipboard

Copied

Add "\r" before it...

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

Copy link to clipboard

Copied

"\rReviewers\r"

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

Copy link to clipboard

Copied

Thanks! when I'm typing the code in notepad and the link gets to be too long, how can I continue on the next line? A simple return doesn't seem to work.

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

Copy link to clipboard

Copied

I think it's working using Retirn now. This thing is so sensitive. I'll make a change and it won't update and then I'll have to delete it and re enter it a few time for it to work. Like it saves a cache or something. 

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

Copy link to clipboard

Copied

If the other fields have a calculated value check the fields calculation order, under More in Prepare Form mode.

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

Copy link to clipboard

Copied

The checkboxes have an Export Value. The Summary field (text field) has the custom calculation script.

 

 

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

Copy link to clipboard

Copied

Can you share it?

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

Copy link to clipboard

Copied

Its going well now. I haven't had an issue on tha last three! How do I add bold to "Client Services\r" and "\rCompliance\r" ?

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

Copy link to clipboard

Copied

That is much more complicated. You will need to use Rich Text Formatting instead of plain text.

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

Copy link to clipboard

Copied

I'll leave it as is. Not starting over lol.

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