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

If/then statement for dropdown and check box

Community Beginner ,
Jan 05, 2024 Jan 05, 2024

How do I write a javascript to select or not select a checkbox based on the answer given in a dropdown? So for example

 

If "yes" is selected in the dropdown, the N/A checkbox is not selected.

If  "no" is selected in the dropdown, the N/A checkbox is selected.

TOPICS
How to , JavaScript , PDF , PDF forms
761
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 ,
Jan 05, 2024 Jan 05, 2024

As validation script of dropdown field, use this:

if(event.value == "yes")
 this.getField("N/A").checkThisBox(0,false);
else if(event.value == "no")
 this.getField("N/A").checkThisBox(0,true);

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 ,
Jan 05, 2024 Jan 05, 2024

As validation script of dropdown field, use this:

if(event.value == "yes")
 this.getField("N/A").checkThisBox(0,false);
else if(event.value == "no")
 this.getField("N/A").checkThisBox(0,true);
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 ,
Jan 05, 2024 Jan 05, 2024

Seems simple enough, but I can't get it. Are there any other settings I should check?

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 ,
Jan 05, 2024 Jan 05, 2024

Check if checkbox name is "N/A" and if dropdown choices are "yes" and "no" or "Yes" and "No", because it's case-sensitive.

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 ,
Jan 05, 2024 Jan 05, 2024
LATEST

That's it! I didn't realize it was case sensitive. Thanks so much for your help and quick reply.

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