Instantly share code, notes, and snippets.

What would you like to do?
Acrobat JavaScript: Change list values based on another list
acrojs_dependentList.js by Joel Geraci is licensed under a Creative Commons Attribution 4.0 International License.
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
For list boxes: Add this script to the "selection change" script of the master list box.
For combo boxes: Add this script to the "custom format" script of the dropdown box.
Edit the following line to identify the field name of the dependent list box then edit the properties of the dependentListValues JSON object. Property names should correspond to the export values of the list items.
var dependentListBoxFieldName = "dependentListBox";
var dependentListValues =
"animal": [
["Dogs", "dogs"],
["Cats", "cats"],
["Pandas", "pandas"]
"mineral": [
["Gold", "Au"],
["Silver", "Ag"],
["Lead", "Pb"]
"veggie": [
["Carrots", "carrots"],
["Broccoli", "broccoli"],
["Spinach", "spinach"]
You probably don't need to change anything from here down
if (( == "combobox" && == "Format") || ( == "listbox" && == "Keystroke")) {
if ( == "combobox") {
if (dependentListValues.hasOwnProperty( {
else {
if ( == "listbox" && dependentListValues.hasOwnProperty(event.changeEx)) {
else {
app.alert("This script was not intended for this field type or event.");

This comment has been minimized.


JoelGeraci commented Nov 27, 2016

Download a functioning example from here.


This comment has been minimized.

bababarghi commented Aug 22, 2018

Thanks for sharing Joel. I am using your code in my PDF Form and it works fine. The only problem is, dependent field gets cleared every time I close and re-open the file. Is there any way that I could save the dependent field value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment