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

Calculate all Checked Boxes in Column and Multiply

New Here ,
May 11, 2023 May 11, 2023

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.

TOPICS
Edit and convert PDFs , JavaScript , PDF , PDF forms
2.1K
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 ,
May 11, 2023 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
May 11, 2023 May 11, 2023

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

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 ,
May 11, 2023 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.

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 ,
May 11, 2023 May 11, 2023
LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

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