Filtering a database

Hi,

We have 2 drop-down menus and a search bar (see below). All three work independently however we want them to work together to filter a career database. See the site here www.careerbiz.online/

If we filter by location it works fine. But when we try to refine the search with a second filter (all classifications) it resets the ‘location’ filter meaning you can’t filter by both ‘location’ and ‘classification’ simultaneously.

Here is what we have called our various inputs.

  • Search bar = ’ #input1

  • Location drop down = ’ #location1

  • Classification drop down = ’ #classification

  • Table = ’ #table1

  • Dataset = ’ #dataset2

  • Database = ‘careers’
    We have not had any luck with this question on previous Wix Forum threads. The full code is below, could anyone help us rewrite it and solve our problem? We would be so grateful!!!

Full code:-

Search bar = ’ #input1
Location drop down = ’ #location1
Classification drop down = ’ #classification
Table = ’ #table1
Dataset = ’ #dataset2
Database = ‘careers’

export function input1_keyPress_1() {
wixData.query(‘careers’)
.contains(‘title’, $w(‘#input1’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
});
}

export function location1_change(event, $w) {
wixData.query(‘careers’)
.contains(‘location’, $w(‘#location1’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
$w(‘#table1’).show();
});

}

export function input1_viewportEnter(event, $w) {
wixData.query(‘careers’)
.contains(‘location’, $w(‘#location1’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
$w(‘#table1’).show();
});
}

export function classification_change() {
wixData.query(‘careers’)
.contains(‘category’, $w(‘#classification’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
$w(‘#table1’).show();
});
}

Hi Harte!

What you’re trying to achieve is multi-field filter.
Take a look at this thread, it should give you the push towards the road you’re seeking!

Anyway, in order to create a multi-filter search , more than one field is required for comparison inside the called function/event.
As I see from the code you posted, in every event that is being called there is only one field to refer to thus revoking other referencing from other fields in other events.
All you’re actually missing is combining those conditions .
Try to read into the WixDataFilter API and look at the examples there.

Also, I’ve noticed that you have asked about this issue before in other threads.
As much as we’d like you to conquer your goals and help you with pointing you to the right direction, in this forum we do not rewrite code for the users but provide them with directions and tools to overcome the issues they’re facing.

If you feel that you need help in rewriting your code you can always turn to the WixArena where you can hire a WixCode expert (and many other kinds of experts) to help you with your site.

Hope it helps!
Best of luck

Doron. :slight_smile: