Help with Code please (Repeaters filter)

Good day to all,

Basically I have a dynamic page that is linked to two databases that previews supplements in a repeater. I am trying to add a dropdown filter with a clear button so that visitors can filter by brand of supplement. When a selection from the dropdown menu is chosen, the Title of page changes to that which the visitor has selected, and it obviously filters the repeater to show only selected Brand. I did not save this work as I am continuously publishing and still experimenting with this and so far it hasn’t worked.

This is the code I am using, I hope you can tell me what I am doing wrong:

//My clear button’s ID is clearButton and has an onClick event called clearButton_click
//My drop down’s ID is selection1 and has an onChange event called selection1_change
//My dynamic page title’s ID is text21.
//I have two databases connected to the dynamic page:
1)SupplementBrandCategory 2)Amino-BCAA
//My dropdown list is connected to SupplementBrandCategory database, labels and values
connected to Title
//My repeater is connected to Amino-BCAA database
//Inside database of Amino-BCAA i added a reference field that references the database SupplementBrandCategory. Its field value is called brandOfSupplement, and its field name is called brand of supplement
//My repeater’s ID is repeater1

Still the code is not working !

import wixData from 'wix-data';

$w.onReady(function () {

});
let selectedCategory = "";

export function selection1_change(event, $w) {
wixData.query("SupplementBrandCategory")
 .eq("title",$w("#selection1").value)
 .find()
 .then( (results) => {
  let firstItem = results.item[0];
  selectedCategory = firstItem._id;

  wixData.query("Amino-BCAA")
   .eq("brandOfSupplement",selectedCategory)
   .find()
   .then( (results) => {
    $w("#repeater1").data = results.items;
    $w("#text21").text = "POST WORKOUTS - " + $w("#selection1").value;
  } )
  .catch( (err) => {
    let errorMsg =err;
   } );
 });
}

export function clearButton_click(event, $w) {
  wixData.query("Amino-BCAA")
        .find()
        .then( (results) => {
         $w("#repeater1").data = results.items;
         $w("#text21").text = "POST WORKOUTS - ALL";
       } )
       .catch( (err) => {
         let errorMsg = err;
       } );
}

I will be extremely thankful to anyone who can tell me what I am doing wrong here!!! :frowning: :frowning:

Really hope someone can help with this !

Hey Im having the same problem. My repeater is not filtering results from the dropdown I created. Were you able to find a solution for this? I noticed your code has some minor differences, here’s mine:

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-Data’;

$w.onReady(function () {
//TODO: write your page related code here…

});
let selectedCategory = (“”);

export function dropdown1_change(event, $w) {
// Query from dropdown change event
wixData.query(“Make”)
.eq(“title”, $w(“#dropdown1”).value)
.find()
.then((results) => {
let firstItem = results.items[0]; //First item in results
selectedCategory = firstItem._id;

		wixData.query("CarDetails") 
			.eq("make", selectedCategory) 
			.find() 
			.then((results) => { 
				$w("#repeater1").data = results.items; 
			$w("#pageTitleText").text = "INVENTORY" + $w("#dropdown1").value; 
			}) 
			.catch((err) => { 
				let errorMsg = err; 
			}); 
	}); 

}

export function button13_click(event, $w) {
//Reload all items when clear button clicked
wixData.query(“CarDetails”)
.find()
.then((results) => {
$w(“#repeater1”).data = results.items;
$w(“#pageTitleText”).text = “INVENTORY”;
} )
.catch((err) => {
let errorMsg = err;
} );
}