Button display

Is there a way to hide a button if certain condition is not fulfilled?
If there is some value in a field in database then the buttons are displayed, if the field is blank then the buttons should not be visible on site, and all the items below that button should adjust accordingly.

Thanks in advance!

Hello

here’s show and hide example:https://www.wix.com/code/home/example/Hide-and-Show-Elements
to check the data base for a certain value use query .

Best
Massa

OK. I tried to do it and was successful in hiding three buttons if data in one of the database field is empty. But I also want to adjust the elements below the hidden elements to move upwards if the buttons are collapsed. The code is shown below.

As far as I read, the collapsed element does not take any space and the elements below the collapsed element are moved upwards. This is not happening on my site. An empty space is left where the three buttons were supposed to be.

Another thing is that I have to keep the properties of buttons at “Collapsed on load”. Otherwise the thing is not working.

$w.onReady( function () {

//Collapse and Show Series Buttons
// get the current item from the dataset
const currentItem = $w(“#dynamicDataset”).getCurrentItem();
// get the current Series Text
const series = currentItem.series;

if (series. null ) {
$w(‘#Series’).collapse()
$w(‘#Booknum’).collapse()
$w(‘#Booknum2’).collapse()
} else {
$w(‘#Series’).expand()
$w(‘#Booknum’).expand()
$w(‘#Booknum2’).expand()
}
});