Skip to main content
Known Participant
April 7, 2019
Question

Trouble With Drop Down Adobe Scripts - Help Please

  • April 7, 2019
  • 2 replies
  • 858 views

Is there a maximum amount of data you can have in a drop down box?

I have a list of 6 clients (I'm starting small just to test)

I have a name, DOB and address.

I am using a script to populate a drop down box which lists all names:

var textFields = ["Aname", "Bname", "Cname", "Dname", "Ename", "Fname"]; 

 

if (event.source!=null && textFields.indexOf(event.source.name)!=-1) { 

    var items = [""]; 

    for (var i in textFields) { 

        items.push(this.getField(textFields).valueAsString); 

    } 

    this.getField("Dropdown1").setItems(items); 

I have also created custom fields to add the name, DOB & address into one field. (AFull Details, BFull Details etc.)  I am then trying to use this field in a drop down.  It seems to work for 5 clients, but when I add the 6th, it doesn't refresh the drop down...

var textFields = ["AFull Details", "BFull Details", "CFull Details", "DFull Details", "EFull Details", "FFull Details"]; 

 

if (event.source!=null && textFields.indexOf(event.source.name)!=-1) { 

    var items = [""]; 

    for (var i in textFields) { 

        items.push(this.getField(textFields).valueAsString); 

    } 

    this.getField("Dropdown2").setItems(items); 

I have changed the formula many times requesting Aname, Bname up to F and it works fine.  I have changed 1 at a time to show AFull Details, Bname etc which again works fine up to 5, but when I change the last one to show all 6 full details, my drop down still contains earlier data, even though I change all 6 fields each time to Test1, Test2  then next time Test01,. Test02 etc.

I need a maximum of 20 eventually, but am stuck getting past 5...

Can anyone help please??

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
April 8, 2019

Try following code:

if (event.source!=null && textFields.indexOf(event.source.name)!=-1) {

    var items = [""];

    for (var i in textFields) {

        var f = this.getField(textFields);

        if (f != null)

          items.push(f.valueAsString);

        else {

            console.show();

            console.println("missing " + textFields);

          }

    }

    this.getField("Dropdown2").setItems(items);

}

Known Participant
April 8, 2019

Hi Bernd, thanks for your reply.  In your script, where do I put my field names please?

Bernd Alheit
Community Expert
Community Expert
April 8, 2019

At the beginning add:

var textFields = ...

Inspiring
April 7, 2019

There are tools that will add the list of the 50 U.S. states and abbreviations into a drop down.

Thom Parker
Community Expert
Community Expert
April 7, 2019

I've put over a 1,000 items in a dropdown.

Are any errors reported in the Console Window when you run the script for 6 items?  Because the most likely issue is an error in the script.

Have you tried simply putting a list of 6 times into the dropdown?

this.getField("Dropdown2").setItems(["a","b","c","d","e","f","g"]);

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
April 8, 2019

Hi Thom, this just sets text a, b, c etc into my dropdown.  I want a, b, c to refer to existing fields in my document.

I can get the drop down working when it pulls through simple data from a name fields for example (name1, name2, name3 etc) but when I use a calculated field to combine name1, address1, date of birth1 and then try to use this new field Full1, Full2, Full3 etc it seems to fail.