is it possible to hide the table if the search box is empty?

hi guys iam trying to configure this one i hope you can help me
this is my current code now.

import wixData from ‘wix-data’;
$w.onReady(function () {
});
export function pindot(roll) {
wixData.query(‘CaffeBeneDBS’)
.contains(‘employeeName’, $w(’ #input1 ‘).value)
.or(wixData.query(‘CaffeBeneDBS’).contains(‘examinationResults’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘evaluatorsName’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘city’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘evaluationType’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘employeesDesignation’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘uniqueIdCode’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘storeName’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘date’, $w(’ #input1 ‘).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘employeesId’, $w(’ #input1 ‘).value))
.find()
.then(res => {
$w(’ #table1 ').rows = res.items;
});
}
hope you can help me

Hi Jerone!

Of course it is possible!
Simply add an if \ else condition.
Looks something like that:

if (res.items.length === 0) {
	$w('#table1').hide();
} else {
	$w('#table1').show();
}

You should put this inside the ‘.then’.

Hope it helps!
Best of luck!
Doron. :slight_smile:

1 Like

hehe sorry for another question in which area will i put that code is it in query section?

Doron alkalay i tried your code and its working but the thing is when you load the page there is a bunch of datain the table that is already showed up that is what i want to get rid off it also.
thank you. for your help

Hi Jerone!
Is the table connected to anything?
What kind of info is showing that you’re trying to get rid of?
Please post a link to your website so we can inspect your site and help you!

Thanks.
Doron. :slight_smile:

Hi boron the table is connected to my database inside the website

when you open the page this is the first load. NOTE: (this table is the one i want to remove every time i load this page and it only shows when i put a text inside the box)
as you can see there is nothing inside the search box but a data is being showed inside the table

the codes that you have given me is only working if the text that i put inside the box is not available inside the table data just like this.

this ones looks perfect if this one works in first page load without any data text inside the box.
apparently not

this is my current code now. i want to be very specific thank you.

import wixData from ‘wix-data’;

$w.onReady(function () {

});

export function pindot(roll) {
wixData.query(‘CaffeBeneDBS’)
.contains(‘employeeName’, $w(‘#input1’).value)
.or(wixData.query(‘CaffeBeneDBS’).contains(‘examinationResults’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘evaluatorsName’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘city’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘evaluationType’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘employeesDesignation’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘uniqueIdCode’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘storeName’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘date’, $w(‘#input1’).value))
.or(wixData.query(‘CaffeBeneDBS’).contains(‘employeesId’, $w(‘#input1’).value))
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
if (res.items.length === 0) {
$w(‘#table1’).hide();
} else {
$w(‘#table1’).show();
}
});
}

Hi Jerone!

Please share with us a link to your site and to the page you’re facing issues with so we can look into it.

Doron. :slight_smile:

https://www.cb.keden.sa/caffebenedbs here you go mate