Skip to main content
Participating Frequently
September 9, 2016
Question

compare 2 comboboxes

  • September 9, 2016
  • 1 reply
  • 397 views

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 has been closed for replies.

1 reply

try67
Community Expert
Community Expert
September 9, 2016

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.

Participating Frequently
September 9, 2016

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

try67
Community Expert
Community Expert
September 9, 2016

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