Skip to main content
January 14, 2026
Answered

Check Boxes and Sum

  • January 14, 2026
  • 2 replies
  • 321 views

Hello together,

I'm trying to create a form, where, if I check a box or boxes, the value will be added as a total sum.

for example:

CheckBox1 = 3

CheckBox2 = 6

Checkbox3 = 3

if 1 + 2 = checked thank the Total in field "TotalSum" should be 9.

If all boxes are unchecked than 0.

 

I tried this script but this works only as "else", not as "and".

sorry, I'm totally new in adobe or scripting...

 

if (this.getField("1.0").isBoxChecked(0))
      event.value = 0; 
else
if (this.getField("1.1").isBoxChecked(0))
      event.value = 3;
else
if (this.getField("1.2").isBoxChecked(0))
      event.value = 6;
else
if (this.getField("1.3").isBoxChecked(0))
      event.value = 3;
else
      event.value = 0; 

Thank you in advance,

Hinnerk

 

Correct answer PDF Automation Station

Please find attached the test form with both pages.


If you check the console for errors you will find the following error:

TypeError: this.getField(...) is null
10:Field:Calculate

 

That means there is a field referenced in line 10 that does not exist.  The field CheckBox2-10 name should be changed to "2.10"

 

https://pdfautomationstation.substack.com/p/the-javascript-console

2 replies

try67
Community Expert
Community Expert
January 14, 2026

Try this:

 

event.value = 0;

if (this.getField("1.1").isBoxChecked(0))
      event.value+=3;

if (this.getField("1.2").isBoxChecked(0))
      event.value+=6;

if (this.getField("1.3").isBoxChecked(0))
      event.value+=3;

      
hinnerkkAuthor
January 15, 2026

Hi try67,

thank you for your quick response.

the problem is, that this code does not sumerize the items or boxes. It just adds the number.

So instead of 3+6=9, it writes 036 in that field.

could you please take a look.

I appreciate your help.

BR Hinnerk

try67
Community Expert
Community Expert
January 15, 2026

Try this:

 

var v = 0;
if (this.getField("1.1").isBoxChecked(0))
      v+=3;

if (this.getField("1.2").isBoxChecked(0))
      v+=6;

if (this.getField("1.3").isBoxChecked(0))
      v+=3;
event.value = v;
PDF Automation Station
Community Expert
Community Expert
January 14, 2026

There is no math in your script, only a list of statements setting the value of the field.  Once one of these statements returns true, the other statements will be ignored.  The easiest way to do this is to set the export values of the check boxes to the values you want in the addition equation when the boxes are checked, then use a suffix naming convention like you have done ("1.0" through "1.3").  Don't use a script in the TotalSum field.  Simply check "Value is the sum of" in the calculate tab and then select "1" (you will see 1.0 through 1.3, but you should also see the root field 1.  Select 1 only).

https://pdfautomationstation.substack.com/p/create-a-check-box-scoring-questionnaire