Explore the community Forums Lectora Lectora Questions & Answers Prevent duplicate droplist choice Reply To: Prevent duplicate droplist choice

#379180 Score: 0
Profile photo of Jason Dalrymple
Jason Dalrymple
Member
beginner
intermediate
profile
wise owl
curious george
contributor
friend finder
advanced
picture perfect
54 pts
@JasonADal

Ok – So I’ve got a start on some JavaScript that accomplishes in a sense what I want to do. It compares the two droplists and gives an alert if the values are equal or not equal. In the final product, I’d take the “else” off the JS, since I don’t care if they’re not equal.

Here’s the rub…In order to do it, I have to set a variable for the value of each droplist, then compare the two values with (===). (It also works with “%HTMLNAME%”, btw).

var droplist1 = document.getElementById(“combo12345id”).value

The JS then compares droplist1 to droplist2 and creates an alert based on whether they are equal or not.

What I’d like to figure out, and am not clear on based on research, to find a way so that the comparison is with all other droplists EXCEPT for itself with some kind of variable. This way, I can run the JS on a button. It’d be awesome if I could get it to work on an onSelectChange, but annoyingly, you can’t copy and paste actions to droplists in a question.

I feel like I’m VERY close on this, but just need to get over one more hump. Here’s a sample of what I have so far.