Skip to main content
Participating Frequently
Sep 9, 2016 9:39 AM UTC
Question

compare 2 comboboxes

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.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

try67
Community Expert
Community Expert
Sep 9, 2016 9:43 AM UTC

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.

Translate
Participating Frequently
Sep 9, 2016 9:45 AM UTC

OK, that is a good tip. But how do i do that then?

Translate
try67
Community Expert
Community Expert
Sep 9, 2016 9:56 AM UTC

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

Translate