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

Using multiple checkboxes to populate text field with the checkbox values

Explorer ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Hi there,

 

Is it possible to click checkboxes and get the value to appear in a text field?

 

Checkbox values are:

Level Life

Increasing Life

Decreasing Life

Level CI_CILC

 

The name of the Text Field is "TextField1".

 

If possible I would like to try and get the textfield populated, if all 4 checkboxes are active, as:

'Level Life | Increasing Life | Decreasing Life | Level CI_CILC '

 

Any help would be greatly appreciated

 

Steve

TOPICS
JavaScript , Modern Acrobat , PDF forms

Views

106

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

correct answers 1 Correct answer

Community Expert , Sep 26, 2024 Sep 26, 2024

You can do it using this code, as the custom calculation script of the text field:

 

var values = [];
if (this.getField("Check Box 5").valueAsString!="Off") values.push("Level Life");
if (this.getField("Check Box 6").valueAsString!="Off") values.push("Increasing Life");
if (this.getField("Check Box 7").valueAsString!="Off") values.push("Decreasing Life");
if (this.getField("Check Box 8").valueAsString!="Off") values.push("Level CI_CILC");
event.value = values.join(" | ");

Votes

Translate

Translate
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

You can do it using this code, as the custom calculation script of the text field:

 

var values = [];
if (this.getField("Check Box 5").valueAsString!="Off") values.push("Level Life");
if (this.getField("Check Box 6").valueAsString!="Off") values.push("Increasing Life");
if (this.getField("Check Box 7").valueAsString!="Off") values.push("Decreasing Life");
if (this.getField("Check Box 8").valueAsString!="Off") values.push("Level CI_CILC");
event.value = values.join(" | ");

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
Explorer ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

LATEST

Brilliant. Many thanks,

 

Steve

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 ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

If you wish to show values when all 4 checkboxes are active, use this as custom calculation script of text field:

var checkedValues = [];
for (var i=5; i<=8; i++) {
 var f = this.getField("Check Box " + i).valueAsString;
  if (f !== "Off") {
   checkedValues.push(f);}}
if (checkedValues.length === 4) {
 event.value = checkedValues.join(" | ");} 
else {
 event.value = "";}

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