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

Check boxes automatically populating a new text field

New Here ,
Mar 24, 2017 Mar 24, 2017

I have 7 check boxes with different results.  I now want to make a text field that brings those results from the checked off boxes to a new text field.  How do I do it?

Example:

say the check boxes are "1", "2", "3", etc.

then in my text field I need to make an If statement, if box 1 and 3 and 5 are checked, then it prints 1, 3, 5

if just 1 is checked, then just "1" will print

Does that make sense?

  FIRST TIME USER !!

TOPICS
Acrobat SDK and JavaScript , Windows
450
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 ,
Mar 24, 2017 Mar 24, 2017

You can use this code as the custom calculation script of your text field:

var fields = ["1", "2", "3", "4", "5"];

var values = [];

for (var i in fields) {

    var f = this.getField(fields);

    if (f.value!="Off") {

        values.push(fields);

    }  

}

event.value = values.join(", ");

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 ,
Apr 06, 2017 Apr 06, 2017

okay i think i have this setup incorrectly -- my check box is 1 and next to it currently i have a text - say Blue - but that has to be a formatted field, correct?  - and then i want another field to print BLUE if check box 1 is checked - - or is there away of labeling the CheckBox 1 - to print BLUE if checked?

i don't even know what i'm asking anymore !  : )

EX:

checkbox1     Obesity

checkbox2     Clots

so on another page if checkbox1 is checked, it will automatically print "Obesity"

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 ,
Apr 06, 2017 Apr 06, 2017
LATEST

You need to set the Export Value for the check box to the text you want displayed. Then the script should work. If you cannot set the export value then you need to add more code to properly fill the array with the text value you want displayed.

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