Skip to main content
Known Participant
September 17, 2018
Answered

Dropdown list to view or hide other fields

  • September 17, 2018
  • 1 reply
  • 1216 views

I wanna create a PDF form that has conditional Dropdown list. For example, dropdown list has values: X, Y & Z. If the user chooses “X” he will see a list of checklist different than when he chooses “Y” or “Z”.. so is this possible to do this using adobe pro DC with javascrips ??. thanks..

This topic has been closed for replies.
Correct answer try67

can u pls give me some example code ??. thanks...


Here's an example:

var fields1 = ["Field1", "Field2", "Field3"];

var fields2 = ["Field4", "Field5", "Field6"];

for (var i in fields1) this.getField(fields1).display = (event.value=="X") ? display.visible : display.hidden;

for (var i in fields2) this.getField(fields2).display = (event.value=="Y") ? display.visible : display.hidden;

1 reply

try67
Community Expert
Community Expert
September 17, 2018

Do you want to show/hide another field, or do you want to set the items available in a field based on the selection?

Both are possible, but require different approaches.

omanbuxAuthor
Known Participant
September 17, 2018

hi, it will be like bellow.

if i select "X" in drop down, bellow that should visible 5 questions & check boxes to select. if i select "Y" in drop down, before 5 questions & check boxes need to disappear & need to visible different 6 questions & check boxes to select in same place. same way i have 5 different drop down selections so same 5 set of questions & check boxes available to hide or display. hope it's clear. thanks..

try67
Community Expert
Community Expert
September 17, 2018

OK. The generic code to do it would be something like this (as the custom validation script of the drop-down field):

if (event.value=="X") {

     this.getField("Field1").display = display.visible;

     this.getField("Field2").display = display.hidden;
} else if (event.value=="Y") {

     this.getField("Field1").display = display.hidden;

     this.getField("Field2").display = display.visible;

}