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

total field for selected checked boxes

New Here ,
Aug 11, 2022 Aug 11, 2022

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. 

TOPICS
Mac
671
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

correct answers 1 Correct answer

Community Expert , Aug 11, 2022 Aug 11, 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.

Translate
LEGEND ,
Aug 11, 2022 Aug 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)

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 ,
Aug 11, 2022 Aug 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? 

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
LEGEND ,
Aug 11, 2022 Aug 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.

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 ,
Aug 11, 2022 Aug 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;

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 ,
Aug 11, 2022 Aug 11, 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.

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 ,
Aug 12, 2022 Aug 12, 2022
LATEST

It finally works! Many thanks for your help!

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