Hi, I have a textbox in a dynamic page which displays url from my dataset. In the dataset some recods contain a url while some do not.
I want a button to be displayed if this textbox contains a url.
The below is the code I used, but it’s not working. I shall appreciate if you could let me know how to fix this.
I kept button’s property as “Hidden on load”
import wixData from ‘wix-data’ ;
export function textbox_viewportEnter(event) { let urlvalue=$w( “#textbox” ).text; if (urlvalue=== ‘’ ) {
$w( “#button” ).hide()
} else {$w( “#button” ).show()}
}
$w.onReady(() => {
$w("#myDataset").onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w("#myDataset").getCurrentItem();
// Checks if the current item has a value in the "url" field
if (item.url) {
// Shows the button if there is a value for "url"
$w("#button").show();
}
});
});
You could also do closer to the tutorial and set the button to show on load and then only hide it if the URL field is empty.