Copy link to clipboard
Copied
Hi,
I'm using adobe Pro to create a form.
I would like to know how i can compare 2 comboboxes. This is needed to prevent that the user makes a combination that is not possible.
Ex.
Combobox1 has the values A, B, C, D and Combobox 2 has the values C, D, E, F.
The user can only combine C+D and D+E but not A+C, A+B, .....etc.
How do i do this in code. I added the export values since i think this can be used for this purpose.
Copy link to clipboard
Copied
Your approach to this task is wrong, I think.
What you really should be doing is to populate the second drop-down field with just the valid values, based on the selection in the first field. That way there can't be an invalid selection.
Copy link to clipboard
Copied
OK, that is a good tip. But how do i do that then?
Copy link to clipboard
Copied
That requires using a script. The basic structure of that script would be something like this (as the custom validation code of the first drop-down);
if (event.value=="A") this.getField("Dropdown2").setItems(["X", "Y", "Z"]);
else if (event.value=="B") this.getField("Dropdown2").setItems(["XX", "YY", "ZZ"]);
etc.
If you're interested, I've developed a tool that allows you to set such a thing up quite easily, without having to write any code yourself.
You can find it here: Custom-made Adobe Scripts: Acrobat -- Create Dependent Dropdowns
Copy link to clipboard
Copied
This solved my problem. Thank you.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now