Hi everyone,
I need your help to configure 3 buttons that appear and disappear when clicked on each one.
The script I wrote is this and buttons 1 and 2 work very well, button 3 does not show me what is inside it when clicked.
When I click button 2 and after button 3, then button 2 remains open.
Can you tell me where I’m wrong?
Thanks a lot to those who want / can help me
Elsa
$w.onReady(function () {
$w(‘#tokyoCollapseButton1’).onClick(() => {
toggleBox($w(‘#tokyoCollapsibleBox1’), $w(‘#tokyoPlusSign1’), $w(‘#tokyoMinusSign1’));
});
$w('#romeCollapseButton2').onClick(() => {
toggleBox($w('#romeCollapsibleBox2'), $w('#romePlusSign2'), $w('#romeMinusSign2'));
});
$w('#madridCollapseButton3').onClick(() => {
toggleBox($w('#madridCollapsibleBox3'), $w('#madridPlusSign3'), $w('#madridMinusSign3'));
});
});
$w.onReady(function() {
$w(‘#tokyoCollapseButton1’).onClick(toggleFront);
$w(‘#romeCollapseButton2’).onClick(toggleBack);
$w(‘#madridCollapseButton3’).onClick(toggleBack);
})
function toggleBox(boxElement, plusSign, minusSign) {
const isCollapsed = boxElement.collapsed;
if (isCollapsed) {
plusSign.hide();
minusSign.show();
boxElement.expand();
}
}
function toggleFront() {
$w(‘#tokyoCollapsibleBox1’).show();
$w(‘#romeCollapsibleBox2’).hide();
$w(‘#madridCollapsibleBox3’).hide();
}
function toggleBack() {
$w(‘#tokyoCollapsibleBox1’).hide();
$w(‘#romeCollapsibleBox2’).show();
$w(‘#madridCollapsibleBox3’).hide();
}
function toggleBack1() {
$w(‘#tokyoCollapsibleBox1’).hide();
$w(‘#romeCollapsibleBox2’).hide();
$w(‘#madridCollapsibleBox3’).show();
}