I am trying to scroll to a section and collapse and expand different sections based on a drop down element. Its currently not working and cant figure out why. Currently I have all text box elements collapsed and below I try to scroll to various sections and reveal specific text elements.
I am new to this and I am sure there is a more efficient way of writing this code but this is where i am at. Any help would be greatly appreciated.
export function dropdown1_change(event) {
$w.onReady(() => {
console.log($w(‘#dropdown1’).value)
$w(‘#dropdown1’).onChange(() => {
let val = $w(‘#dropdown1’).value;
if (val === "2 pizzas") { $w('#text30').scrollTo() }
$w("#text30").expand();
$w("#checkboxGroup3").expand();
//$w("#checkboxGroup4").collapse();
//$w("#text32").collapse();
//$w("#text33").collapse();
//$w("#text34").collapse();
//$w("#checkboxGroup5").collapse();
//$w("#checkboxGroup6").collapse();
//$w("#checkboxGroup7").collapse();
if (val === "4 pizzas") { $w('#text31').scrollTo() }
//$w("#text30").collapse();
$w("#text31").expand();
$w("#text32").collapse();
$w("#text33").collapse();
$w("#text34").collapse();
$w("#checkboxGroup3").collapse();
$w("#checkboxGroup4").expand();
$w("#checkboxGroup5").collapse();
$w("#checkboxGroup6").collapse();
$w("#checkboxGroup7").collapse();
if (val === "6 pizzas") { $w('#text32').scrollTo() }
$w("#text30").collapse();
$w("#text31").collapse();
$w("#text32").expand();
$w("#text33").collapse();
$w("#text34").collapse();
$w("#checkboxGroup3").collapse();
$w("#checkboxGroup4").collapse();
$w("#checkboxGroup5").expand();
$w("#checkboxGroup6").collapse();
$w("#checkboxGroup7").collapse();
if (val === "8 pizzas") { $w('#text33').scrollTo() }
$w("#text30").collapse();
$w("#text31").collapse();
$w("#text32").collapse();
$w("#text33").expand();
$w("#text34").collapse();
$w("#checkboxGroup3").collapse();
$w("#checkboxGroup4").collapse();
$w("#checkboxGroup5").collapse();
$w("#checkboxGroup6").expand();
$w("#checkboxGroup7").collapse();
if (val === "10 pizzas") { $w('#text34').scrollTo() }
$w("#text30").collapse();
$w("#text31").collapse();
$w("#text32").collapse();
$w("#text33").collapse();
$w("#text34").expand();
$w("#checkboxGroup3").collapse();
$w("#checkboxGroup4").collapse();
$w("#checkboxGroup5").collapse();
$w("#checkboxGroup6").collapse();
$w("#checkboxGroup7").expand();
})
})
}