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

Need help with creating a dropdown that creates options in a separate dropdown

New Here ,
Mar 22, 2024 Mar 22, 2024

Copy link to clipboard

Copied

I'm a little familiar with scripting, and the research that I have done for help on this issue, I'm having a hard time locating.

 

I want to create a form where a dropdown list will have category law codes in it.  When that is chosen, a second drop downlist provides descriptions of the law codes within that category.   And then depending on the selection of the 2nd dropdown list, the form will provide the law code itself.

 

An example.  Ohio Revised Code has a category for Theft, which is 2913.  Another category is Drug offenses, which is 2925.  So the first dropdown would be each of these categories would be 2913, 2925, etc.

 

Then depending on which category is selected, the 2nd dropdown would contain a list of all descriptions in that category.  2913 has (just to name a few) Theft; Forgery; Identity Fraud.  2925 has (to name a few) Drug Possession; Drug Instruments Possession.  

 

Then the form would provide the actual law code itself depending on what the 2nd dropdown list is.  An example is if Theft is selected, then it would show "2913.02 A", or Identity Fraud as "2913.49 A 1".  Or Drug Possession would show "2925.11"

 

There would be a couple hundred criminal codes for the 2nd dropdown list.  An example is "Theft - without privilege to do so", then "Theft - beyond the scope", then "Theft - by Deception", etc, but each one of these has it's own code itself.  Theft - without privilege is 2913.02 A 1.  Theft beyond scope is 2913.02 A 2, Theft by deception is 2913.02 A 3.

 

so, the form would be to select the category, "2913" as an example.  Then select the description "theft by deception" then the form produces the criminal code "2913.02 A 3"

 

Any help would be appreciated.  Is there an easier way than what I have described?

 

TOPICS
PDF forms

Views

123

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 Beginner ,
Mar 22, 2024 Mar 22, 2024

Copy link to clipboard

Copied

Try67 makes an add-on to build these types of dependent dropdown menus...

 

https://www.try67.com/tool/acrobat-create-cascading-dropdowns

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 ,
Mar 22, 2024 Mar 22, 2024

Copy link to clipboard

Copied

This question has been asked a many times for many years. You'll find post and code related to this issue on this forum.

Here's an article and sample that covers this exact issue:

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

 

You'll also find more related solutions and everything you ever wanted to know about list fields here:

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

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 ,
Mar 24, 2024 Mar 24, 2024

Copy link to clipboard

Copied

I appreciate the rapid response, however, the solution you posted isn't going to be useful to my scenario because I will have a few hundred options in different dropdowns, so adding each one in the script would be a tedious task.

 

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 ,
Mar 24, 2024 Mar 24, 2024

Copy link to clipboard

Copied

LATEST

The options have to be somewhere.   The issue you describe is not about the methodology presented in the article, but about loading the data. The methodology is valid for any number or configuration of list items. You may need to change the structure of the data object for the desired solution, but, the fact is that if you want a selection in one dropdown to set the options in another dropdown, then the option data has be separated from the form fields involved.   

 

So the issue here is how do you handle very large lists of options.  One common solution is to put the options into a CSV file. Then a script could be written to import these options and place them into a document level script. The doc script is the method used to store the options in the form. Document scripts are run when the document is opened. The only job of this doc script is to create the object that controls mapping between the selections. Once the data is imported into the doc script, the form can be distributed for use. If the data changes, you change it in the CSV file and then re-run the script for loading it into the form, and re-distribute the form.

 

So this gives you an easy way to maintain and load the options used in the form.

 

 

 

 

 

 

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