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

Check Box If Statement

New Here ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

I have a simple IF statement in pdf fillable form.  If a checkbox is checked, then "See Below" will display in another field.  Works great!  However, when I uncheck the box, the field still displays the message and doesn't go blank.  Even the Clear Form doesn't clear the field.  HELP!  Thanks.

TOPICS
PDF forms

Views

765

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 2 Correct answers

Community Expert , Feb 25, 2022 Feb 25, 2022

So then, this must be a calculation script on the field that is displaying the "See Below" text?  It's extremly important that we know where the script is being run. 

There are a few problems with the script, it's not that close. 

1.  the comparison operator is "=="

2.  is the export value from the checkbox 1? This is also crtical information. 

3.  There is no variable named CRO, the vaiable containing the checkbox value is named TEST.

 

Here is a calculation script that will work regardless of

...

Votes

Translate

Translate
Community Expert , Jul 17, 2024 Jul 17, 2024

You can use something like this as custom calculation script of text field:

var cList = [
 "Text for checkbox1", 
 "Text for checkbox2", 
 "Text for checkbox3", 
 "Text for checkbox4",
 "Text for checkbox5" 
];
event.value = "";
for(var i=0; i<=4; i++){
 var f = this.getField("Check Box"+i).valueAsString;
 if(f !== "Off")
  event.value += cList[i]+"\n";}

This assumes checkboxes are named "Check Box0","Check Box1",...etc, you can add more checkboxes just change to correct number in loop.

Votes

Translate

Translate
Community Expert ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

What script does you use?

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

I am very new to using script, so hope I am not too far off!  CRO is a checkbox for a class running outside business houirs.

 

var TEST = this.getField("CRO").value;
if( CRO = 1) event.value = "See Below"
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
Community Expert ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

So then, this must be a calculation script on the field that is displaying the "See Below" text?  It's extremly important that we know where the script is being run. 

There are a few problems with the script, it's not that close. 

1.  the comparison operator is "=="

2.  is the export value from the checkbox 1? This is also crtical information. 

3.  There is no variable named CRO, the vaiable containing the checkbox value is named TEST.

 

Here is a calculation script that will work regardless of the export from the checkbox.

 

var TEST = this.getField("CRO").value;
if( TEST != "Off") event.value = "See Below";
else event.value = "";

 

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

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

PERFECT!  I am so glad you are there to help!

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

You're welcome. I'd be helpful if you marked my answer as Correct.

 

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

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Hi Thom,

I am new to scripting in Adobe.  I am trying to make a form, that has a list of items that has checkboxes next to them.  What I want to happen is when a checkbox is checked, some specific text will fill a text box below the list.  And as other items are checked, specific text for them are added to the text box.
Is this possible?
Thanks!

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

You can use something like this as custom calculation script of text field:

var cList = [
 "Text for checkbox1", 
 "Text for checkbox2", 
 "Text for checkbox3", 
 "Text for checkbox4",
 "Text for checkbox5" 
];
event.value = "";
for(var i=0; i<=4; i++){
 var f = this.getField("Check Box"+i).valueAsString;
 if(f !== "Off")
  event.value += cList[i]+"\n";}

This assumes checkboxes are named "Check Box0","Check Box1",...etc, you can add more checkboxes just change to correct number in loop.

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

LATEST
Thank you!!!

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

Please provide the script that is used for this action, and be specific about where the script is triggered. For example, is the script in the MouseUp Action for the checkbox?

 

 

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

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

The script is in the Calculation of the Test Field.

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