Hello everyone,
I am trying to enter a simple code to hide a button on a dynamic page, but it doesn’t work for me. I’m already desperate. I also looked for similar topics, for example this, but it still doesn’t work for me. (https://forum.wixstudio.com/t/hide-or-show-buttons-based-on-database-entry/32920)
I have a database of items that visitors can reserve and I need the item to be marked as already reserved after filling out a Wix Form. At the same time, I would like the button for Reserving an item to be hidden, for those items that are no longer available. Everything is connected to the database and displayed using a dynamic page.
I tried these two procedures:
1)
Add a checkbox to the page that is connected to the database and shows me which item is available and which is no longer available. I then added this code to $w.onReady(function () …
if ($w(“#checkbox2”).checked === true) {
$w(“#button15”).hide();
}
It doesn’t work, button15 is always hidden
I also tried this code, checking the availability of the item directly through the database:
$w(“#ydynamicDataset”).onReady(() => {
var item = $w(“#dynamicDataset”).getCurrentItem();
if (item[“spare”] === false) {
$w(“#button15”).show();
} else {
$w(“#button15”).hide();
}
});
It’s not functional either.
At the same time, I have a Form on the WIX page and an added checkbox field connected to the CMS. When I check the checkbox and submit the form, I would like the item to be marked in the database as unavailable = reserved. I have a boolean column there. I thought it would go automatically, but it doesn’t do anything. I guess some code has to be added.
Thanks in advance for any help.