On my dynamic page, I am trying to have my table appear depending on whether or not they have a specific tag.
$w.onReady(function () {
});
export function button3_click(event, $w) {
let d = $w(“#input3”).value;
let c = $w(“#input4”).value;
if(d === "1" && c === "2") {
$w("#button3").hide();
$w("#table1").show();
}
}
Currently, I have to use a button to have the table display because if you use the on ready function, the variables d and c get assigned a null value I think. I believe this because when using the onReady function and using console to log the values of d or c the debug console crashes and the page breaks. Does anyone know a way around this so that I don’t need to use a button to display the table after the page loads?
Hi Hardcore Dragon,
You can use onChange handlers for your inputs.
$w.onReady(function () {
//TODO: write your page related code here...
$w('#input3').onChange(() => {
let d = $w("#input3").value;
let c = $w("#input4").value;
if(d === "1" && c === "2") {
$w("#button3").hide();
$w("#table1").show();
}
});
$w('#input4').onChange(() => {
let d = $w("#input3").value;
let c = $w("#input4").value;
if(d === "1" && c === "2") {
$w("#button3").hide();
$w("#table1").show();
}
});
});
Let me know if that helps.
Thank you for the quick response, but sadly this only works if the value actually changes, the two inputs are just readable so you can’t actually change their contents. Although if you do change the contents by me allowing this to be true, it works, but I can’t let the user change their tag at any moment, that is why it needs to be only readable. Do you know of any other way this could be done or a way around this issue? Also I am thankful for this already because it is a step in the right direction I believe.
So if i understood correctly inputs are binded to values from dataset. Then i think what you need is onReady handler which runs when dataset is ready. Check it out here.
Thank you so much!!! That worked!