Enable and Disable button based on database element

I want to enable and disable a button based on the value that is in the database.
I linked that cell to a text on my wix page but its not working
Here is the code,

$w.onReady( function () {
//TODO: write your page related code here…

let processedAnwser = $w(‘#text125’).text; // textbox linked to database

if (processedAnwser === “yes” || processedAnwser === “Yes”){
$w(‘#button28’).enable();
}
else {
$w(‘#button28’).disable();
}
} );

1 Like

Try something like this, however this might be over doing it and you will need to match up the curly brackets and parentheses to make sure that you have equal pairs of open { and ( and close } and ).

$w.onReady( () => {
$w("#myDataset").onReady( () => {

$w('#text125').value = $w("#myDataset").getCurrentItem().fieldName; 

if ($w('#text125').value === 'Yes') {
$w('#button28').enable();
}
else{
$w('#button28').disable();
}
});

hi,

i tried what you did above. It works but like it disables the other buttons on the repeater. Is there another way to do that?

maybe trying to disable it using each row id in the collection and not element id because in repeaters each element use the same id in the other boxes in that repeater. and one function will affect the other rows on the page

I’m thinking maybe after getting the id a user used to post to my collection, then use the if statement you did above. but idk how to code that in

thanks in advance,

Post a screenshot of your code.

In a repeater you change $w to $item