Copy link to clipboard
Copied
I'm new to Javascript in PDF forms. I'm trying to put a combobox (named "Additional Users") on a PDF form that populates with values from an array. According to this help page, it looks like you can use a 2D array to store the keys and values for the combobox.
What I've done will populate the combobox, but once you select an option and click away from it, the value resets to the first option, which in this case is 0. In fact, even the example code from the help page does the same thing when I try it out in my form. What am I doing wrong?
var dropdown = this.getField("Additional Users");
dropdown.setItems([ ["0", 0], ["5", 5], ["10", 10], ["15", 15] ]);
Yes, it is. I just didn't realize that this would be something dynamic, until now...
If the values are dependent on the selection in a radio-button group then you should put this code as the MouseUp event of those buttons.
Copy link to clipboard
Copied
Where did you place this code?
Copy link to clipboard
Copied
On the combobox item, as a custom calculation script.
Copy link to clipboard
Copied
That means it will execute each time the value of any field in the file, including that one, is changed.
You only need to run this code once. You can do it from the console window and that's it.
Copy link to clipboard
Copied
The final code will actually be part of a switch statement, though. If the user selects a certain radio button, then this combo box will have one set of options, and if they select another radio button, it will have a different set of options, etc. There are four radio buttons. So the combo box cannot populate until the user makes a selection, and if they change their selection, it should repopulate.
Isn't the console window just for debugging?
Copy link to clipboard
Copied
Yes, it is. I just didn't realize that this would be something dynamic, until now...
If the values are dependent on the selection in a radio-button group then you should put this code as the MouseUp event of those buttons.
Copy link to clipboard
Copied
Thank you very much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now