I am having difficulty in showing a hidden id based on the boolean value in the database.
The code I am using is:
export function dynamicDataset_ready() {
let nikunj = $w("#dynamicDataset").getCurrentItem().ShowQuote;
if(nikunj === true) {
$w('#wixquotes1').show();}
else {$w('#wixquotes1').hide();}
}
I want to show the id wixquotes1 if the boolean value in the field ShowQuote is true.
The above code is not working.
Please help.
Hi,
I don't see in your code where it gets the value from the database. From what I see the text box is always empty.
In your original code, you need to use the Field Key and not the Field Name.
It should be showQuote, not ShowQuote.
Yisrael
Hi Tal,
I've worked on the above code and realized that I needed to use Collapse and expand I/O Show and Hide.
I am now trying to expand or collapse an element based on the value of a text box.
The text box gets the value from the database.
My New Code is as below:
$w.onReady(() => { if (Number($w('#text4').value) !== 0) { console.log("Here") $w("#wixquotes1").expand() } else { console.log("Else") $w("#wixquotes1").collapse() } });
Somehow this code always shows up in console.log ("Else")
Am unsure whats going on.
My programming skill Level is Novice so sorry to bother you.
Thanks,
Hi,
I would console log the variable nikunj to check if you get any result when getting the current item (before the if statement). Click here to learn more about debugging your code.
Good luck!
Tal