Hi, I have a repeater populated via 2 search fields, 2 dropdowns and 2 sliders, additionally the count of the filtered items is shown in a text box. All that functions pretty well. I had to copy the whole search for the two tasks (repeater and count) as I didn’t find a way to run it with one search only. I’m sure there is a way to do that, I just don’t know how as my coding skills are only two weeks young… Can anyone point me in the right direction, please?
function search() {
wixData.query( ‘Fahrzeuge’ )
.contains( ‘type’ , $w( “#searchBar1” ).value)
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘bundesland’ , $w( “#dropdown2” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘modell’ , $w( “#dropdown1” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘title’ , $w( “#searchBar2” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).ge( ‘baujahr’ , $w( “#slider1” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).le( ‘baujahr’ , $w( “#slider2” ).value))
.find()
.then(res => {
$w( ‘#repeater1’ ).data = res.items;
});
wixData.query( ‘Fahrzeuge’ )
.contains( ‘type’ , $w( “#searchBar1” ).value)
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘bundesland’ , $w( “#dropdown2” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘modell’ , $w( “#dropdown1” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).contains( ‘title’ , $w( “#searchBar2” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).ge( ‘baujahr’ , $w( “#slider1” ).value))
.and(wixData.query( ‘Fahrzeuge’ ).le( ‘baujahr’ , $w( “#slider2” ).value))
.count()
.then((num) => {
let numberOfItems = num;
$w( ‘#countText’ ).value = num;
})
}