Hi everyone, I tried searching for a topic that covered this question but couldn’t find it – so apologies if it’s been asked before.
I am a coding novice so I would appreciate help with the syntax, as well as the logic.
—MAIN PROBLEM—
I am trying to filter the results of a database, based on user input from 3 drop-down menus, and display the results on a repeater.
I have successfully connected the repeater to the database, and the results display correctly. The problem lies with filtering those results.
—SITE—
I am making a travel agent web site, where the user selects items from below drop-down menus.
Menu #1
Name of cruise line - TEXT
Menu #2
Destination - TEXT
Menu #3
Duration of cruise (in number of nights) - NUMBER
—WHERE I AM STUCK—
When the page loads for the first time, all results appear which is fine.
- When I click on the Results button without selecting anything from the drop-down menus, no results appear.
Ideally it should show all results, unfiltered.
- If I select a cruise line name from Menu #1 but leave the other two menus blank, nothing appears
Ideally it should show all results that contain the selection from Menu #1
- If I select a cruise line name from Menu #1 and an option from Menu #3 sometimes the results are correct, but not consistently.
I suspect the problem lies here . I cannot filter the results correctly when numbers are concerned.
The choices for Menu #3 (total number of nights for the cruise) are
All (with a value of 0)
Less than 7 nights (with a value of 7)
Between 7-14 nights (with a value of 14)
More than 14 nights (with a value of 1000 because there are cruises which are 200+ nights)
Maybe there’s a way to take the value of the dropdown Menu #3 before I filter the database, and assign it to an absolute value when it falls between a certain range, and then compare that absolute number to the database?
This is my only code so far
export function buttonResults_click(event, $w)
{
$w(“#dynamicDataset”).setFilter(wixData.filter()
.contains(“company”,$w(‘#dropdownCompany’).value)
.contains(“title”,$w(‘#dropdownDestination’).value)
.le(“numberOfNights”,$w(‘#dropdownNights’).value))
}
Any help will be much appreciated.
Thanks in advance!
Panagiotis