2 Replies Latest reply on Jul 1, 2014 11:50 AM by gkaiseril

    cities javascript pulldown


      Does anyone know where I can find javascript that has listed all the the US cities that I can use in a PDF pulldown window?

        • 1. Re: cities javascript pulldown
          MichaelN Level 3

          I don't know of any pre-defined script which has US cities. I found a list of 385 US cities here: Text List of US Cities | Jordon Meyer - eCommerce Search Marketing


          Once you have your list of cities, it is easy to populate your combo box using a script, using the setItems() method in Acrobat.

          This is an example from the JavaScript for Acrobat API reference:


          var l = this.getField("ListBox");

          l.setItems(["One", "Two", "Three"]);


          This script will populate the "ListBox" combo box with 3 items: "One", "Two", "Three".


          You can use a text editor to create the list of US cities in the format shown in line 2 of the script above, then run the script from the console (press Control J to open the console) to populate your combo box.

          • 2. Re: cities javascript pulldown
            gkaiseril MVP & Adobe Community Professional

            I would use a combo box field unless you want to enable multiple selections. The provided script would be placed as a document level script to populate the field upon the opening of the PDF. It also allows for easier editing of the box and values.


            I would make the code a function and use parameters for the field name and value array so I could reuse the code to populate many combo boxes or list boxes within a single form


            function SetItems(cField, aValues) {
            // poplate a named field with the the option and optional value;
            var oField = this.getField(cField);
            if(oField == null) app.alert("Error accessing field " + cName, 1, 0);
            try {
            } catch (e) { app.alert("Error setting field values", 1, 0);
            } finally {
            } // end try;
            } // end SetItems funciton;


            var aValues = new Array("One", "Two", "Three", ["Four", 4]);
            SetItems("ListBox", aValues);