Skip to main content
Participant
August 11, 2022
Answered

total field for selected checked boxes

  • August 11, 2022
  • 2 replies
  • 776 views

What is the correct custom script for the field suming all checked boxes (Check Box6.1, Check Box 6.2 and Check Box6.3)? Appreciate your help! I tried to read previous posts on total of check boxes but those scripts didn't work. 

This topic has been closed for replies.
Correct answer Nesa Nurani

Give checkboxes export value to be 1. Now use built-in function in text field under 'Calculate' tab select 'value is the' and then pick your checkboxes.

2 replies

Legend
August 11, 2022

From your description (which is good, but please do include the actual script you write) you are trying to sum something that isn't a number. Check boxes are on or off, but they aren't something you can add up or sum. What you need to do is COUNT the boxes which are checked (by looking at each box in turn to see if it is checked). This will indeed need JavaScript.

Participant
August 11, 2022

I found this script from another post, but I wasn't sure how to add "Check Box6.1" and "Check Box6.2" to this script:

 

var total = 0;

for (var i=1; i<=90; i++) {

if (this.getField("cb"+i).value!="Off") total++;
}

event.value = total;

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 12, 2022

Give checkboxes export value to be 1. Now use built-in function in text field under 'Calculate' tab select 'value is the' and then pick your checkboxes.

Legend
August 11, 2022

Please show your last effort, so we can help you understand what's wrong, and fix it, rather than just write it for you.

Also say what type of action it is (eg mouse down, validate, calculate)

Participant
August 11, 2022

Okay, I will try my best to describe what I did. First I created two check boxes ("Check Box6.1" and "Check Box6.2") and I chose 'yes' to export value for both boxes. I chose mouse down under action for each box. Both boxes do not have the calculation option. I then created a text box to function as a total for counting all checked boxes and formated it as number with 0 decimal places . I chose mouse down for this text box ("6 #). This field value isn't validated. I tried to calculate it by having it suming both Check Box6.1 and Check Box6.2, but it didn't work. I believe I need to type a custom script to make it countable. I hope this is clear enough for you to follow?