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

If/Then Statement with Dropdown List

Community Beginner ,
Dec 31, 2021 Dec 31, 2021

Hello,

 

I am using Adobe Pro DC and attempting to create a form with IF/THEN statements and dropdown lists. I have looked at all of the similar questions in the community, but was unable to find exactly what I needed. 

 

Here's what is needed:

 

Dropdown 1 will list men, women, or children. 

Drowdown 2 will list shirt sizes based on the selection in dropdown 1. 

 

So IF children is selected in Dropdown 1, how do I make sure that ONLY certain options are available in Dropdown 2?

 

Thank you!

TOPICS
JavaScript , PDF forms
3.4K
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
2 ACCEPTED SOLUTIONS
Community Beginner ,
Dec 31, 2021 Dec 31, 2021

Hi! I actually found a youtube video tutorial that had exactly what I was looking for. Here's my code and it works. 

 

var genderlist = this.getField("Gender");

if(event.willCommit)
{
switch (event.value){

case "Man":
genderlist.setItems(["-Select Size", "Small", "Medium", "Large", "XL", "2XL"]);
break;

case "Woman":
genderlist.setItems(["-Select Size", "Small", "Medium", "Large", "XL", "2XL"]);
break;

case "Child":
genderlist.setItems(["-Select Size", "2T", "3T", "4T", "5T", "X-Small"]);
break;

}

}

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 Beginner ,
Dec 31, 2021 Dec 31, 2021
LATEST

Sorry, I forgot to mention that I input this into Dropdown 1 under Custom Keystroke Script.

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 ,
Dec 31, 2021 Dec 31, 2021

So you want to load a list (i.e. dropdown) based on the selection from another list?

This has be asked many times. Here are some articles, with examples, that cover this issue.

 

https://acrobatusers.com/tutorials/js_list_combo_livecycle/

https://acrobatusers.com/tutorials/change_another_field/

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

 

  

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 ,
Dec 31, 2021 Dec 31, 2021

Hi! I actually found a youtube video tutorial that had exactly what I was looking for. Here's my code and it works. 

 

var genderlist = this.getField("Gender");

if(event.willCommit)
{
switch (event.value){

case "Man":
genderlist.setItems(["-Select Size", "Small", "Medium", "Large", "XL", "2XL"]);
break;

case "Woman":
genderlist.setItems(["-Select Size", "Small", "Medium", "Large", "XL", "2XL"]);
break;

case "Child":
genderlist.setItems(["-Select Size", "2T", "3T", "4T", "5T", "X-Small"]);
break;

}

}

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 ,
Dec 31, 2021 Dec 31, 2021
LATEST

Sorry, I forgot to mention that I input this into Dropdown 1 under Custom Keystroke Script.

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