Highlighted

Cascading / Dependent dropdown lists using Acrobat DC Standard

Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

Hi,

 

I have tried searching a lot and am yet to come across a self-help solution/code to create cascading / dependent dropdown lists (Combo box) using Acrobat DC Standard. 

 

The closest match I found was a Creative Commons Custom Format free script (can't seem to find the link now) which had a bug where in the form resets when it is saved and reopened. 

 

Would appreciate any other suggestions.

 

 

TOPICS
PDF forms

Views

87

Likes

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

Cascading / Dependent dropdown lists using Acrobat DC Standard

Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

Hi,

 

I have tried searching a lot and am yet to come across a self-help solution/code to create cascading / dependent dropdown lists (Combo box) using Acrobat DC Standard. 

 

The closest match I found was a Creative Commons Custom Format free script (can't seem to find the link now) which had a bug where in the form resets when it is saved and reopened. 

 

Would appreciate any other suggestions.

 

 

TOPICS
PDF forms

Views

88

Likes

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
Aug 31, 2020 0
Adobe Community Professional ,
Aug 31, 2020

Copy link to clipboard

Copied

You'll find solutions here:

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

This solution shows how the basic operations are handled. However, dependent series of lists create a state problem, because the state of the current list entered into the down stream list field is maintained dynamically in the code. This state is lost when the field is closed.  This is not a bug, it's an incomplete solution. There are two easy solutions for restoring this state. One is to follow the selection chain to restore the dynamic state. The second is to save the dynamic state as JSON in a hidden text field.  Ideally, you'd use an object at runtime to maintain this state. 

 

You'll find a more advanced solution here as well as a ton of scripts and sample PDFs(but it is not free):

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

The solutions presented here are more advanced and include a statmp      

Likes

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
Reply
Loading...
Aug 31, 2020 0
Community Beginner ,
Aug 31, 2020

Copy link to clipboard

Copied

Thank you for your response. 

 

Due to my limited understanding of JavaScript, I searched for another logical but easier way to solve this via Show/Hide dropdown lists and came across this linkIn the options panel, check the box that says "Commit selected value immediately" then add your code to the Custom Format Script of the Master dropbox.

 

Sample I customised to suit my need (posting here to assist others) that seems to be working well so far:

Note that everything after "//" are comments for you to understand the code. Append IF and Else statements similarly for additional dependent dropdown fields that you'd like to show/hide. The only downside I can think of is that I need to create as many dependent Combo Box fields as the number of options in the Master List. Welcome all constructive feedback. 

 

var v = this.getField("MasterList").value; //Replace MasterList with the Master/predecessor field name
if (v === "Option1") { //Replace Option1 with the first dropdown option value from the MasterList
this.getField("ComboBox1").display = display.visible; //Replace ComboBox1 with the first Combo Box (Dropdown list) field name
}
else {
this.getField("ComboBox1").display = display.hidden;
}
if (v === "Option2") {
this.getField("ComboBox2").display = display.visible;
}
else {
this.getField("ComboBox2").display = display.hidden;
}

 

 

Likes

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
Reply
Loading...
Aug 31, 2020 0
Adobe Community Professional ,
Sep 01, 2020

Copy link to clipboard

Copied

Showing and hiding fields is a solution to a different problem than the dependant dropdown problem you asked about. If you want help you need to describe the actual problem you are trying to solve (which you still haven't done).  Here's an article on everything you need to know about hiding and showing fields.

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40

 

 

Likes

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
Reply
Loading...
Sep 01, 2020 0
Community Beginner ,
Sep 03, 2020

Copy link to clipboard

Copied

I took an alternate approach by creating seperate dropdown (combo box) fields each corresponding to an option in the master dropdown list. It worked well for the four options I had to cater to however, I know it can get cumbersome for more options.

 

E.g. If master dropdown list is called State with options such as VIC, NSW, NT, SA, etc.; I created separate dropdown list fields to show the list of Cities within each state for instance City_VIC field would have options such as Melbourne, Brunswick, Northcote, etc. Similarly City_NSW, City_NT and so on were created. All City fields were overlayed on top of each other at the same position in the form.

 

Then I applied the above code to the master dropdown State to show only that City field list which corresponded to the selected State.

 

Hoping this would help other users in future. 

Likes

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
Reply
Loading...
Sep 03, 2020 0
Most Valuable Participant ,
Sep 01, 2020

Copy link to clipboard

Copied

If you're interested I've created a (paid-for) tool that allows you to set it up very easily (based on a spreadsheet) without having to write any code. You can find it here: http://try67.blogspot.com/2014/11/acrobat-create-cascading-dropdowns.html

Likes

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
Reply
Loading...
Sep 01, 2020 0
Adobe Community Professional ,
Sep 01, 2020

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Sep 01, 2020 0
Community Beginner ,
Sep 03, 2020

Copy link to clipboard

Copied

This is perfect. Thanks a ton!

 

I had found an older version of this file which had a bug that reset the dependent combo box selection after saving, closing and reopening the file. The one you have shared seems to be working well. 

 

Thank you to all who contributed.

Likes

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
Reply
Loading...
Sep 03, 2020 0