Hey guys & gals. Thanks to you lot I have a search on my web-site using 2 pull-down boxes to then filter the results to meet the clients needs by selection.
My original database display has filters put in, but not needed to be by code. But the Search Button code needs filters added again.
I list my code below and would like to add a filter into the displayed records. Basically I have a field named "avail" which contains "Y" or BLANK. I only want to list ones that say "Y".
Current code:
======================================
import wixData from 'wix-data';
//For full API documentation, including code examples visit http://wix.to/94BuAAs
$w.onReady(function () {
//TODO: import wixData from 'wix-data';
});
export function searchButton_onClick(event) {
wixData.query('TopSanta')
.contains('airport', $w('#selection1').value)
.contains('duration', $w('#selection2').value)
.ascending("airport", "date", "duration")
.limit(100)
.find()
.then(res => {
$w('#table1').rows = res.items;
$w('#table1').show();
});
}
======================================
ONCE AGAIN THANKS ALL YOU GUYS!! :-)
Thanks Giri. :-)
This should work:
export function searchButton_onClick(event) {
wixData.query('TopSanta')
.eq("avail", "Y")
.contains('airport', $w('#selection1').value)
.contains('duration', $w('#selection2').value)
.ascending("airport", "date", "duration")