Hello! I'm very new to coding and have been trying to work around my wixsite with simple codes.
I want to make the button element (#button27) gray out and disable the link when the database's field text consists of the word "open"
it should look like this:
![](https://static.wixstatic.com/media/a27d24_5ea4c5bc743a43d99a5fe9b187a5d50d~mv2.png/v1/fill/w_332,h_173,al_c,q_85,enc_auto/a27d24_5ea4c5bc743a43d99a5fe9b187a5d50d~mv2.png)
and vice versa, enable link when text consists of the word "closed".
![](https://static.wixstatic.com/media/a27d24_de11fac6ceb749038a32b5b3af2cdc3d~mv2.png/v1/fill/w_313,h_166,al_c,q_85,enc_auto/a27d24_de11fac6ceb749038a32b5b3af2cdc3d~mv2.png)
These words will specifically located in:
- content manager named "Status" (#dataset5)
- in the field name "Commission Status" with field key commissionStatus.
- has field type text. which will consist of the word "closed" and "open"
with a note: the database text will change from close to open or vice versa from time to time.
+ the text element showing "open" and "close" word have this ID #text54 connecting to the "Status" collection database (#dataset5).
I've tried mix-matching some codes to my knowledge after browsing for the solution. Like this based on https://www.wix.com/velo/forum/coding-with-velo/enable-and-disable-button-based-on-database-element
$w.onReady( () => {
$w("#dataset5").onReady( () => {
$w('#text54').value = $w("#dataset5").getCurrentItem().commissionStatus;
if ($w('#text54').value === 'Yes') {
$w('#button27').enable();
} else {
$w('#button27').disable();
}
});
$w('#button28').disable()
});
But it doesn't work... I know the code is probably wrong somewhere and unfinished... but I have no idea how to code it...
Also tried this code but not working too (from https://www.wix.com/velo/forum/coding-with-velo/hide-an-element-if-a-text-element-contains-a-certain-value )
$w.onReady( () => {
if ($w("#text54").text.includes("Open")) $w("#button27").disable();
});
Please help me.. thank you in advance!
I'm trying to understand what exactly is your setup. What do you mean by "unlink the Lightbox window on the button"? Do you just want to disable the button so the site visitor can't open the Lightbox? As shown above in the different code snippets, all you need to do is to disable the button like this:
$w('#button27').disable();
What else are you trying to do?
Hello. $w("#myDataset").onReady isn't pointing to your dataset, so your code is never executing. Change it to $w("#dataset5").onReady. So the whole code should look like:
$w.onReady( () => {
$w("#dataset5").onReady( () => {
$w('#text54').value = $w("#dataset5").getCurrentItem().commissionStatus;
if ($w('#text54').value === 'Yes') {
$w('#button27').enable();
} else {
$w('#button27').disable();
}
});
}