Import or copy list into dropdown list with export values
Copy link to clipboard
Copied
I have 100+ items along with unique export values I would like to add to a dropdown list. I've seen a few posts about pasting multiple items into a dropdown list, but I haven't found one that also inlcudes the Export Values.
Copy link to clipboard
Copied
You can find an example in the Acrobat Javascript Reference.
Copy link to clipboard
Copied
You can try like this:
this.getField("Dropdown").setItems([["GEOG 101", "3"], ["GEOG 101L", "1"], ["GEOG 102", "3"]]);
Copy link to clipboard
Copied
@Nesa Nurani is it also possible to force the setItems command to include leading zeroes on the export values? I know how to do this in other situations using 'valueAsString', but I can't figure out how to make that work when setting the dropdown items dynamically. For example, how would I adjust the below to ensure the export value included the leading zeroes?
var dropDownVal = [["one", 01], ["two", 02], ["three", 03]];
var field = this.getField("Numbers");
field.setItems(dropDownVal);
Copy link to clipboard
Copied
E.g. replace 01 with "01"
Copy link to clipboard
Copied
Wow, that is so easy I hadn't even considered it. Thank you, @Bernd Alheit !
Copy link to clipboard
Copied
As mentioned, this can be done using the setItems method, by specifying an array of arrays as the input parameter.
Note that the first item in the array is the default one.
If you're interested, I've developed a paid-for tool that allows you to do it directly from a text file, including importing export values, easily and quickly. You can find it here: https://www.try67.com/tool/acrobat-import-items-from-a-text-file-to-a-combo-box-or-list-field

