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

Calculation resulting from checkbox selection in a PDF

New Here ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

I am very new at creating custom calculation scripts, and I don't know how to do the following:

I need to calulate the total of all fees associated with the boxes checked:

    DisneyMickeyGirl_0-1670093678566.png

The checkboxes are titled Checkbox1, Checkbox2, etc.

The exception is the custom fee boxes, that's where I'm getting stuck. If those checkboxes are clicked, they will enter a dollar amount in the FEE1-FEE3 fields.

The Total will be calculated in a "Total Fees" field.

Is this possible?

Thank you VERY much for your help!

Views

752

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 , Dec 03, 2022 Dec 03, 2022

You can do it using this code (I assumed the names of the check-boxes are Checkbox1 to Checkbox10):

 

var total = 0;
for (var i=1; i<=7; i++) {
	var v = this.getField("Checkbox"+i).valueAsString;
	if (v!="Off") total+=Number(v);
}
if (this.getField("Checkbox8").valueAsString!="Off") total+=Number(this.getField("FEE1").valueAsString);
if (this.getField("Checkbox9").valueAsString!="Off") total+=Number(this.getField("FEE2").valueAsString);
if (this.getField("Checkbox10").valueAsString!="Off") total
...

Votes

Translate

Translate
Community Expert ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

 

<moved from using the community>

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 ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

You can do it using this code (I assumed the names of the check-boxes are Checkbox1 to Checkbox10):

 

var total = 0;
for (var i=1; i<=7; i++) {
	var v = this.getField("Checkbox"+i).valueAsString;
	if (v!="Off") total+=Number(v);
}
if (this.getField("Checkbox8").valueAsString!="Off") total+=Number(this.getField("FEE1").valueAsString);
if (this.getField("Checkbox9").valueAsString!="Off") total+=Number(this.getField("FEE2").valueAsString);
if (this.getField("Checkbox10").valueAsString!="Off") total+=Number(this.getField("FEE3").valueAsString);
event.value = total;

 

In order for it to work, though, you must set the export values of the first 7 check-boxes as the price for that item (without the dollar symbol, just as a number).

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 ,
Dec 04, 2022 Dec 04, 2022

Copy link to clipboard

Copied

LATEST

Thank you VERY much Try67 - that worked perfectly! I've seen your other replies - you are such a blessing to this community, I appreciate you!

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