Skip to main content
xaiv1225
Participant
May 11, 2023
Question

Calculate all Checked Boxes in Column and Multiply

  • May 11, 2023
  • 2 replies
  • 2081 views

I am trying to create a form to add up only the checked boxes in each column, and then multiply the total by that column number. I am not familar with javascripting, so for column 1, I've used the calculate option in the 1Rating text box properties.

Thanks.

This topic has been closed for replies.

2 replies

Nesa Nurani
Community Expert
Community Expert
May 11, 2023

Just add column number as export value and it should calculate as if you multiply total.

xaiv1225
xaiv1225Author
Participant
May 11, 2023

After posting this, I did just that and set each check box with the export value of their column, but I didn't think ahead to some how also limiting each row/question to be able to select only one box, either 1, 2, 3. This method allows them to click all three boxes, which doesn't help, unless I can restrict them to only select one box for each question.

Thom Parker
Community Expert
Community Expert
May 11, 2023

That was the point of asking whether the buttons on a single line were mutually exclusive or not.  To make them mutually exclusive you'll need to give all the buttons on a single line the same name. You can read more about it here:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

To show the different sums for each column you'll need to use a script that sorts for the different export values. It would help if all of the checkboxes in all rows were prefixed with the same name. 

For example "Checkbox.Row1", "Checkbox.Row2", etc.

 

Then the code could be written like this for column 1:

var nSum = 0;
this.getField("Checkbox").forEach(function(oFld){if(a.valueAsString == "1") nSum+= 1;});
event.value = nSum;

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
May 11, 2023

So, do the checkboxes in a single line have the same name (i.e. mutually exclusive)? or do they have different names?  

What are the export values for the checkboxes in each column?

 

Have you looked at other posts about adding checkboxes and radiobuttons?

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often