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

Calculation resulting from checkbox selection in a PDF

New Here ,
Dec 03, 2022 Dec 03, 2022

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.pngexpand image

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!

999
Translate
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
1 ACCEPTED SOLUTION
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+=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).

View solution in original post

Translate
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

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>

Translate
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

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).

Translate
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
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!

Translate
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