6 Replies Latest reply on Feb 11, 2013 8:41 AM by try67

# How do I subtract a value from a given value using checkboxes?

I'm new to Adobe Acrobat Pro and my JavaScript skills are non-existent. I would greatly appreciate some assistance with a scoresheet I am trying to create.

I have a total of 100.00% in a final score box, and I want 4.16 subtracted every time a checkbox on that sheet is checked.

So, for example, I have 24 blocks that can be checked, labeled "AL1Check Box25" through "AL1Check Box48."

I have a total score box, labeled "AL1_FINAL_SCORE," that has a value of 100.00%

Every time a box from "AL1Check Box25" through "AL1Check Box48" is checked, I want a value of 4.16% to be subtracted from the 100.00% of "AL1_FINAL_SCORE."

I tried to set as an average, but Adobe automatically rounds up to 4.17, since 100/24 = 4.16666666667. I need to round down to 4.16.

• ###### 1. Re: How do I subtract a value from a given value using checkboxes?

Use this code as the custom calcluation script of your Total box:

var discount = 0;

for (var i=25; i<=48; i++) {

var f = this.getField("AL1Check Box"+i).value;

if (f.value!="Off") discount++;

}

event.value = 100 - Math.floor(discount*4.16);

• ###### 3. Re: How do I subtract a value from a given value using checkboxes?

Sorry for the late response. Thank you for the formula, but it doesn't appear to be working. I wonder if it has to do with the settings in the properties of the boxes.

For the AL1_Final_Score box, I have the default value set to 100, and the format category as Percentage, allowing 2 decimal places.

For AL1Check Box25 through AL1Check Box48, I have the export value as 0.

The AL1_Final_Score box automatically shows 100.00%, like I want, but when I check any of the range of mentioned check boxes, there is no change to the final score.

• ###### 4. Re: How do I subtract a value from a given value using checkboxes?

Is the field format set as Percentage? If so, then you need to replace this line:

event.value = 100 - Math.floor(discount*4.16);

With this:

event.value = (100 - Math.floor(discount*4.16))/100;

Also, try to be a bit more specific about what exactly is not working... And check the JS console for errors.

• ###### 5. Re: How do I subtract a value from a given value using checkboxes?

I ran the code through JS debugger, and got the following messsage:

Type Error: this.getField ("AL1Check Box" + i) is null

1:Console:Exec

When I said that it wasn't working, I meant that when I click on one of the Check Boxes, there is no change to the final score.