Skip to main content
Jeff512
Inspiring
March 2, 2026
Answered

counting checkboxes

  • March 2, 2026
  • 4 replies
  • 78 views

I feel like this is an easy issue?? but I'm not getting the Text box on page 12 (Next to the word Record) to add the check boxes.

I have an attendance roster (Page 12) and want a count of all Check Boxes checked.

I created a txt box at the top next to the word Record. 

I am aware that some code dose not like spaces. 

I thought it might be a syntaxes error. between “Check Box” and “CheckBox” so I adjusted the name of the boxes for the first 15 days in July to “CheckBox” . I have tried both.

 

// Initialize counter variable
var sum = 0; 
// Loop through the fields
for (var i = 126; i < 499; i += 1) {
// Add one if check box is not Off
    if (getField("CheckBox" + i).value !== "Off") {sum += 1;}

// Set this field's value to the sum
event.value = sum;

    Correct answer Jeff512

    Ok Solved

    for some reason “Check Box227” was missing.

    So Added a it and a “Check Box499” set the values to hidden and the code works great!!!

    4 replies

    JR Boulay
    Community Expert
    Community Expert
    March 3, 2026

    There is no need for JavaScript to perform such a simple calculation.
    See the attached example.

     

     

    Acrobate du PDF, InDesigner et Photoshopographe
    Jeff512
    Jeff512Author
    Inspiring
    March 3, 2026

    Check Box227 not 127

    Jeff512
    Jeff512AuthorCorrect answer
    Inspiring
    March 3, 2026

    Ok Solved

    for some reason “Check Box227” was missing.

    So Added a it and a “Check Box499” set the values to hidden and the code works great!!!

    try67
    Community Expert
    Community Expert
    March 2, 2026

    Add this line inside your loop:

    console.println(i);

    Then open the JS console, and tick one of the fields, and you’ll see what the issue is.

    Jeff512
    Jeff512Author
    Inspiring
    March 2, 2026

    Ok output “Is null”??

    I tried changing the output value to 1 before I sent the request for help/

    so what’s the solution.???

    try67
    Community Expert
    Community Expert
    March 3, 2026

    The issue is that some of the field names you're trying to access are incorrect. The code I provided will help you locate which ones, as it will be the last number shown in the list before the code errors out.