Skip to main content
Known Participant
March 8, 2021
Answered

Three drop-down menus with condition.

  • March 8, 2021
  • 5 replies
  • 5027 views

Hello. As a continuation of the question (Two drop-down menus with condition.)...

 

There are three drop down menus

DROPDROP 2DROP 3
AAA
BBB
CCC
DDD
EEE
FFF
GGG
HHH


Which script can be used to exclude repetitions in each subsequent menu?

For example, in the DROP menu I selected "A",

then in the DROP 2 and DROP 3 menus exclude "A",

and after selecting "B" in DROP 2, exclude it from DROP 3 (and "A", respectively).

Of course, the entries in the menu can be selected in free order (and not alphabetically or in order)

 

 I am assuming that every field (A, B, C, etc.) need to assign a value.

 

But what script can I use for this, I don’t know?

Unfortunately, I did not find this example either on YouTube or on other forums.

 

Thank you.

This topic has been closed for replies.
Correct answer bebarth

Hi,
Since each target drop-down menu is directly linked to its mother drop-down menu with a same index, you don't have to use a so complex script as the one I gave you. A simpler one is enough.
Attached are your pdf file including the scripts and my txt working file.
Let me know if something is wrong.
@+

5 replies

bebarth
Community Expert
bebarthCommunity ExpertCorrect answer
Community Expert
March 11, 2021

Hi,
Since each target drop-down menu is directly linked to its mother drop-down menu with a same index, you don't have to use a so complex script as the one I gave you. A simpler one is enough.
Attached are your pdf file including the scripts and my txt working file.
Let me know if something is wrong.
@+

Known Participant
March 11, 2021

Hello.

Sorry for not responding right away .. (email got into spam)

This is perfect for me.
Many thanks.

bebarth
Community Expert
Community Expert
March 10, 2021

Hi,

I just saw this post so I adapted a script I did some times ago to your 3 drop-down menus example.

Is it something like this you wish?

@+

Known Participant
March 10, 2021

Hello bebarth.

Yes, this is also a good option (although I do not need the "Target" cells. I will do a test a little later (I will need to assign 80 values to the data) and later I will report the result.

 

Thank you.

try67
Community Expert
Community Expert
March 8, 2021

The script is quite simple. As the custom validation script of "DROP", for example, enter this:

 

var v1 = this.getField("DROP 2").valueAsString;
var v2 = this.getField("DROP 3").valueAsString;
if (event.value==v1 || event.value==v2) {
	app.alert("Error! You can not select the same value twice.");
	event.rc = false;
}

 

Just adjust the field names in the first lines to use it for the other fields.

 

Known Participant
March 9, 2021

Hello. Thanks for your reply.

Perhaps I am doing something wrong, but so far I have not been able to get the desired result. Perhaps the fact is that, by default, all menus have a field: -Select SUBSECTION-

 

Thank you.

 

try67
Community Expert
Community Expert
March 9, 2021

In that case you need to exclude that item from the code above, or you'll constantly get error messages.

Try this:

 

if (event.value!=event.target.defaultValue) {
	var v1 = this.getField("DROP 2").valueAsString;	
	var v2 = this.getField("DROP 3").valueAsString;
	if (event.value==v1 || event.value==v2) {
		app.alert("Error! You can not select the same value twice.");
		event.rc = false;
	}
}

 

If it still doesn't work please share your file with us for further help.

JR Boulay
Community Expert
Community Expert
March 8, 2021

You will find the same question here, for 6 menus instead of 3, and the answer:

https://abracadabrapdf.net/forum/index.php/topic,4181.0.html

 

(Google Translate is your friend, you must be logged to download attached samples)

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
March 8, 2021

Hello.

I'm not entirely sure if this is my case. I have a script how to register it manually. But this is not an option for me.

I have over 80 (A,B,C,D, etc) fields in one menu.

 

Thank you.

Bernd Alheit
Community Expert
Community Expert
March 8, 2021

What are the default values of the three dropdowns?

Known Participant
March 8, 2021

Hello Bernd.

I think A = 1, B = 2, C = 3 etc.

Thank you.