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

Shortcut for adding export value of checkboxes

New Here ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

I have created a form of 20 pages with about 50 checkboxes on each page. The checkboxes have an export value of 1 and are calculated in a separate text field on each page using the sum function. This is extremely tedious and time-consuming to set up because I have to use "pick" and select all 50 boxes on each of the 20 pages. So I was thinking I could copy all of the field names into a word document and add a + between each one. The only difference in the fields between the pages is the first letter. I could then use find and replace to switch out the previous letter for the new letter and copy and past back into simplified field notation rather than using the sum function. I was so excited. It doesn't work. Does anyone know why? This is a sample of what I copy and paste into simplified field notation: 

h.0.0+h.0.1+h.0.2+h.0.3+h.0.4+h.0.5+h.1.0+h.1.1+h.1.2+h.1.3+h.1.4+h.1.5+h.2.0+h.2.1+h.2.2+h.2.3+h.2.4+h.2.5+h.3.0+h.3.1+h.3.2+h.3.3+h.3.4+h.3.5+h.4.0+h.4.1+h.4.2+h.4.3+h.4.4+h.4.5+h.5.0+h.5.1+h.5.2+h.5.3+h.5.4+h.5.5+h.6.0+h.6.1+h.6.2+h.6.3+h.6.4+h.6.5+h.7.0+h.7.1+h.7.2+h.7.3+h.7.4+h.7.5+h.8.0+h.8.1+h.8.2+h.8.3

Thank You!

TOPICS
JavaScript , PDF forms

Views

1.2K

Translate

Translate

Report

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 28, 2021 May 28, 2021

Copy link to clipboard

Copied

The names of the fields in your screenshot do not start with "h" but with "i" or "l" or something like that.

At any rate, I would use a script for it, instead of the Simple Field Notation. You'll have much greater control over how it works and could use a loop to add them all up much more easily.

Votes

Translate

Translate

Report

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 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Thank you. Do you know where I can find a list of scripts to copy and paste from?

Votes

Translate

Translate

Report

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 29, 2021 May 29, 2021

Copy link to clipboard

Copied

You can do it like this:

 

var fields = this.getField("h").getArray();
var total = 0;
for (var i in fields) {
	total+=Number(fields[i].valueAsString);
}
event.value = total;

 

 

Votes

Translate

Translate

Report

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 29, 2021 May 29, 2021

Copy link to clipboard

Copied

LATEST

Sorry, forgot they were check-boxes...

Replace this line in the code above:

total+=Number(fields[i].valueAsString);

With this:

if (fields[i].valueAsString!="Off") total++;

Votes

Translate

Translate

Report

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 29, 2021 May 29, 2021

Copy link to clipboard

Copied

For the calculation use the entry "Value is the sum of the following fields".
At the button "Pick..." select only the entry "h".

Votes

Translate

Translate

Report

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 29, 2021 May 29, 2021

Copy link to clipboard

Copied

To make it work in SFN you would need to use it like this: h\.0\.0+h\.0\.1
Or you can make a loop like this:
var total = 0;
var fields = [
"h.0.0","h.0.1","h.0.2","h.0.3","h.0.4","h.0.5",
"h.1.0","h.1.1","h.1.2","h.1.3","h.1.4","h.1.5",
"h.2.0","h.2.1","h.2.2","h.2.3","h.2.4","h.2.5",
"h.3.0","h.3.1","h.3.2","h.3.3","h.3.4","h.3.5",
"h.4.0","h.4.1","h.4.2","h.4.3","h.4.4","h.4.5"]
for (var i in fields)
if(this.getField(fields[i]).valueAsString != "Off")
total++;
event.value = total;

Add more fields if needed and you can replace 'h' in another software for other checkboxes.

Votes

Translate

Translate

Report

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