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

Assistance with Dynamic Dropdown Fields

New Here ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

Hello Adobe Community,

 

I am a total noob when it comes to Javascript I am trying to create a nice document for our team using Acrobat DC and can't figure this thing out at all I have read about 15 documents and seen people request money for Tooling and Assitance although, I uderstand the why I want to try and somewhat do this on my own but could use a bit of guidance on how to put it all together especially when dealing with an uknown langauage.

This Document is to keep track of Hardware. I currently have Four Dropdown Fields:

  • Description
  • Model
  • Serial Number
  • Cost

I have listed, every Option for each drop down manually but really want it to Autopopuate the selctions accross the board when a Description option is selected for example.

 

If I select "Dell Windows Laptops" from Decription, I would only like to see a small list of Dell Laptops models, then selecting the model will give me the serial numbers, and then finally the cost of the item.

So far from everything I have read I stared litely and started to test and try and understand I found a bit of code from another Community Entry and I listed it as followed in the Description Dropdown under Actions I selected "Commit Selected Value" and the Action to run a script and this script reads as followed, please keep in mind I have no idea what I am doing and all of these selection dropdowns are pretty big. Once I understand the proper syntax and see it all working I will fill in the blanks.

switch (event.value) {

    case "Dell Windows Laptop": 

        this.getField("Model").setItems(["Latidue 5400","Latitude 5410","Latitude 5420","Percision 3551","Percision 3541"]); 

        break; 

}

But when selecting Preview then selecting "Dell Windows Labtops" the Model dropdown stilll shows all the Options and not the ones only on the script.

 

Is there anyone that would lend a hand as I am totally lost on this. 

Thank You in Advanced.

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

387

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 ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

You're asking about a somewhat complicated, and advanced, scripting task. So it's not something that can be easily answered. For example, everthing depends on how you organize your data. You have a list of vendors, and then a list of products for each vendor, then a list of associated data for each product. The natural organaization for this is a linked list tree. Then you need to write code to navigate this tree as selections are made, filling in (and clearing) the relavant fields, and maintaining the current seletion state.  

 

Here are some articles that explain how to do just this. 

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

https://acrobatusers.com/tutorials/list_and_combo_in_lc/

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

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 ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

Yea that sounds overly complicated indeed, and I know nothing of JavaScripting so this has not become an Impossible task for me and can see I am over my head on this one. I wish it was simplier than that. Thanks for the reply.

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 ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

LATEST

As mentioned, this is a complicated task. You're on the right track, but you'll need to build a data-model that contains all the values you want to display and then convert that to a script that will populate the other fields based on the initial selection.

 

I call this structure "cascading dropdowns" and have developed a (paid-for) tool that will allow you to set it up very easily.

All you need to have is a spreadsheet that contains all of this data and it will take care of the rest for you.

You can find it here: 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