SOLVED Show or hide element in dynamic page depending on boolean

I’ll apologize straight away because I’m totally new at this, but I’ve been googling this for hours now and I can’t solve it.

I have a dynamic page and on these pages I would like to hide, or show, an element(just a small icon/vector art) depending on the boolean value in the database. If true show, if false hide.

import wixData from 'wix-data';

$w.onReady(function () { 
$w("#dynamicDataset").onReady(() => { 
let items = $w("#dynamicDataset").getCurrentItem(); 
if (items["test"]) { $w("#testtext").show(); }
else   $w("#testtext").hide();
}); 

“test” is the name of the field(boolean field) in the database. “testtext” is the ID of the element on the page.

That’s what I currently have and it’s obviously placeholders but I’m really tearing my hair trying to figure it out. I’ve looked through probably all the forums posts related to this and read documentation upon documentation, but it seems I’m currently too dumb to solve it myself.

1 Like

I solved it using this tutorial https://support.wix.com/en/article/corvid-tutorial-hiding-a-video-player-when-there-is-no-video-to-play

Code I used is below if anyone else is similarly new as I am.

$w.onReady(() => {
    $w("#dynamicDataset").onReady(() => {
 const item = $w("#dynamicDataset").getCurrentItem();
 if (!item.test) {
            $w("#testtext").hide();
        }
    });
});

greatly appreciated

Thank you very much, I have been looking for the solution for a long time.