Hi,
I was wondering if someone might be able to offer some advice, I have some code that I'm trying to execute that will show the relevant box below, the .show works but I can't get the rest to hide once the new box has shown.
I can't seem to work out this line for (let y = 2; y <6; y--) I have read lots of articles and watched some videos but seem to be stuck.. Basically if #headerTxt4 is called and shown then it would hide #headerTxt 2 3 5 6 skipping { i }
for (let i = 2; i <=6; i++){
$w(`#headerTxt${i}`).onClick((event)=>{
$w(`#menuBox${i}`).show()
for (let y = 2; y <6; y--)
$w(`#menuBox${y}`).hide()
})
}
Thank you
Hi,
Your seconds for loop is infinite, I'd recommend you to learn more about for loops here.
This code block creates a click event for three buttons which shoes only the text with same index, modify it to match your needs.
for(let i=1;i<4;i++){ $w(`#button${i}`).onClick((event)=>{ $w(`#text${i}`).show(); for(let y=1;y<4;y++){ if(y !== i) $w(`#text${y}`).hide(); } }); }
Good luck,
Or
Your code is unclear. Try to explain what you're trying to achieve.