Example (deprecated): Remove duplicates from connected dropdown options

#Database #Collection #query #filter #debounce #dropdown #duplicates #arrays #Example

This example has been deprecated. See the updated Example: Remove duplicates from connected dropdown options using distinct() query .



Yisrael…yes, this works great! The threads are so full of the “old” examples of this search. Perhaps would be good to eliminate all those threads? FYI, when clicking on email notifications, it at first comes up as 504 bad gateway. Refreshing clears the screen, but thought WIX might want to know. Started showing up yesterday.

Also, how would one add on another dropdown to this?

@jeff-haskins , to add another dropdown, you would just have to duplicate the first dropdown stuff for the second. You could try playing with the functions and make them “generic” enough to use for both, but that might get you into trouble. I would probably create “carbon copies” just to sure it works, and then try to consolidate once it works.

While I have your ear…when you add items to the dropdown menu database, they appear in order added. I notice that on databases, even if you apply a sort such as A to Z, it shows up for you in looking at database, but even if you change the live database, they still appear in the dropdown as order of added. hmm

Ya know something @jeff-haskins , I just knew , absolutely k n e w , that someone was going to ask about sorting the list. So why didn’t I put it in? Well, it’s payback for all those years of school where the textbook would ask a question and then state: “the solution is left up to the reader”. Oh how I hated that.

OK - I just finished lunch (minute steak sandwich accompanied by a stout beer), so I’m in a generous mood… All you need is to add .ascending(“continent”) after the .limit(1000) statement in the query.

Something tells me that I’m just gonna add this to the example.


1 Like

Another thing of note for folks using this code for your repeater. If you are using next/previous buttons and ONLY click on a drop down menu and not use the text search, the buttons will not work to flip through as a sort only shows what is on screen (how many you have limited to show). ONLY after doing both the text search or text plus menu search or no search at all will the previous/next work. Breakfast time here…but that lunch sounds good…where the heck was the invite?

OK @jeff-haskins , you twisted my arm. I’ve added the sort to the example. The stout was excellent.

Perhaps you should have them pour you up one or two more…then I can keep adding questions! LOL, have a great one!

1 Like

The wife and I had lunch together. I was doing the pouring, and the sandwich preparation. Minute steak sandwiches with onions and a fried egg. And the stout. Absolutely over-the-top lunch.

Have a good one. See you around the forums.

@yisrael-wix FYI, the template is the key to any of these tutorials. A lifesaver for really understanding and should be mandatory for any coding examples


So …you are still in the learning process. What you may not realize is that there is a very slim probability that you will find a code to match your exact setup.

Every code can be written in many many ways. A long way, a short way, an efficient way, an advanced way, a dataset way, an all code way, etc etc etc

It would be truly impossible to show every single possible use case scenerio for every person.

The point of the tutorials is to teach you THAT specific way so you can learn the fundamental logic behind the combination of code that lead to that specific combination of a solution so you can apply that logic in your own creation of code.

As you continue to practice you will start seeing all the different ways to accomplish each goal you have. You will have lots of fun in your journey.

Happy coding.

Hi, @yisrael-wix ! I have a view of your live Example and the dropdown option is what I was looking for but the codes has been mixed up with the search function. Are there any way you can provide me the different code for the search button and for the dropdown button? I would really love to add this feature to my website. Please please please. Thank you! <3

1 Like

We are unable to provide code solutions. The example demonstrates how to use both filter methods together, If you wish to use a dropdown by itself, or a search by itself, then just remove the code for the undesired filter method.

@yisrael-wix I have the dropdown working. Yay! :smiley: I am just unsure how to work with the search filter though but still. www.freedfox.com/design-ideas :smiley:

I tried everything and cannot make it work.
Can someone help me with this? I can’t make it to work. I know how to add the element, rename it, but every time I go on preview mode and enter something in the search box, everything disappear.

Dear @yisrael-wix , would that be possible to remove duplicates from a combination of a text box (Heading1, entity) + dropdown (Select a period, period1) both stored in dataset in a dynamic page? So that when showing the dropdown list (Select a period), only the “period” entries corresponding to the Heading 1 (here the company) are displayed:

my current code currently only affects the period without taking into account the text value which is also a table field:

$w.onReady( function () {
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown3”).options = buildOptions(uniqueTitles);
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.period1);
return [… new Set(titlesOnly)];
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return { label: curr, value: curr };

@code-queen Dear Nayeli, maybe you ca help on the below topic? thanks in advance,