Skip to main content
Participating Frequently
January 6, 2022
Answered

How to set the export values for dropdown list in Adobe PDF JavaScript?

  • January 6, 2022
  • 2 replies
  • 5582 views

I want to set the Export Values for a dropdown list in an Adobe pdf form using javascript. This is the code I have currently in the document-wide javascript:

var dropDownVal = ["one", "two", "three"];
var dropDownExportVal = [1, 2, 3];

var field = this.getField("Numbers");

field.setItems(dropDownVal);
field.exportValues(dropDownExportVal);

The dropdown list is populated with the dropDownVal array but the properties of the cell show no export value. Any assistance or links to documentation would be great.

This topic has been closed for replies.
Correct answer try67

You need to use a 2D-array as the parameter for setItems, like this:

 

var dropDownVal = [["one", 1], ["two", 2], ["three", 3]];
var field = this.getField("Numbers");
field.setItems(dropDownVal);

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 6, 2022

You need to use a 2D-array as the parameter for setItems, like this:

 

var dropDownVal = [["one", 1], ["two", 2], ["three", 3]];
var field = this.getField("Numbers");
field.setItems(dropDownVal);
Participating Frequently
January 6, 2022

This worked, thank you so much!

Legend
January 6, 2022

exportValues is a property, not a method. You assign to it, rather than call it. See the example in the API Reference. Also, the array should contain strings. Did you get an error in the JavaScript console? I'd expect one.

Participating Frequently
January 6, 2022

Hey there, thanks for the reply. Here is the updated code based on your suggestions, is this correct? Unfortunately, the export values are still not showing:

var dropDownVal = ["one", "two", "three"];
var dropDownExportVal = ["1", "2", "3"];

var field = this.getField("Numbers");

field.setItems(dropDownVal);
field.exportValues = dropDownExportVal