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

Text depending on 3 checkboxes

Community Beginner ,
Jul 22, 2023 Jul 22, 2023

What i would like.....

 

Checkbox 1 is Apple, Checkbox 2 is Pear, Checkbox 3 is Grape

When one or more checkboxes are checked i like to seen the fruit in in a textfiled."fruit"

Expample:

Checkbox 1 and 3 are checked the textfield "fruit" is: "Apple, Grape"

If just checkbox 2 is checked is should be "Pear" 

Checkbox 1 en 2 "Apple, Pear" or all " Aplle, Pear, Grape"

 

Can anyone help me??

I searched a lot but its hard for me to understand what is the right thing for me

TOPICS
JavaScript , PDF , PDF forms
285
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
1 ACCEPTED SOLUTION
Community Expert ,
Jul 22, 2023 Jul 22, 2023

Use a custom calculation script in the target "textfiled". (I just used the name you provided)

There are many different ways this could be done. 

The code below is one of the more novice level scripts. But its not the best way. 

 

var aOut = [];
if(this.getField("CheckBox 1").value != "Off")
   aOut.push("Apple");
if(this.getField("CheckBox 2").value != "Off")
   aOut.push("Pear");
if(this.getField("CheckBox 3").value != "Off")
   aOut.push("Grape");

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

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

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 ,
Jul 22, 2023 Jul 22, 2023

Use a custom calculation script in the target "textfiled". (I just used the name you provided)

There are many different ways this could be done. 

The code below is one of the more novice level scripts. But its not the best way. 

 

var aOut = [];
if(this.getField("CheckBox 1").value != "Off")
   aOut.push("Apple");
if(this.getField("CheckBox 2").value != "Off")
   aOut.push("Pear");
if(this.getField("CheckBox 3").value != "Off")
   aOut.push("Grape");

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

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Jul 22, 2023 Jul 22, 2023
LATEST

Thnx Thom,

 

It did what it had to do.

How easy can it be 😉 

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