Javascript responds to Data

Hey!

I stuck with this problem!
In a database a column says ‘Pro’ and the item value is ‘false’. I want to hide an element like a box at the specific item page because the value is false. But if the value is true the box is visible. Does anyone know how to do this in Javascript?

I don’t know much about Javascript so I hope you guys can give me a clear explanation.

Thanks in advance!

Can you tell me where are you planing to setup the box? Is it on a dynamic page? If so, what are the page keys that are used to build its URL?

Please give me details so I can help you.
Ahmad.

Hey Ahmad!
Thanks for your response.

It is on a dynamic page. The url is domain.com/studio/{title}.

Quin, on the dynamic page, you need to get the current item from the dataset, first of all, you have to make sure that page and the dataset have finished loading in order for this to work.

$w.onReady( () => {
    $w('#dataset').onReady(async () => {
        let item = await $w('#dataset').getCurrentItem();
        let memberIsPro = item.pro;
        
        if (memberIsPro === true) {
            $w('#onlyForProBox').show();
        }
    })
})

That’s it, and sorry to reply late, I was kind of busy.
Anyways, I hope that helped :wink:

Ahmad

So, if I understand it correctly, the name of the column in the database is ‘memberIsPro’ and its type is ‘text’. Is that correct?

I’ll edit my answer, and mark the field in the database with blue, and the box ID that you want to show with orange okay?

yes! Thank you!

You’re welcome :kissing_smiling_eyes:
Glad that I helped!

Hey Ahmad!

It works! I’m so thankfull. :heart_eyes:

Awesome! I’m happy that I helped :blush: