Hi,
I have a couple of products (building supplies) that I can sort via two dropdown menues. But if the first drop down menu "dropdown1" = anithing but "pipes", I want the other dropdown menu to disapear. The other dropdown "dropdown 2" is for choosing the diameter of the pipe (wich is no longer relevant if you choose for example "wall" or "cable ladder".
I saw this post with my exact ptoblem but I cant get the code right.
https://community.wix.com/velo/forum/coding-with-velo/hide-drop-down-list-based-on-value-of-another-drop-down-list
export function typeddl_change(event, $w) { let value = event.target.value; if(value === 'pipes') { $w('dropdown2').show(); } else { $w('#dropdown2').hide(); } }
I am new to Wix editor and programming in general so help is much appreciated.
The only issue in the code you provided is that you missed a # in $w('dropdown2').show(). Other than that the only reason why it wouldn't work is if you have deleted the event handler from the dropdown or have spelt the function name wrong. An option would be to switch to using $w("#dropdown").onChange((event) => {
Where dropdown is the id of your first dropdown menu.
Though if you want a completely different way to achieve this you can use selectedIndex and do something like this:
$w("#dropdown").onChange(() => {
const dropdownSelIndex = $w("#dropdown").selectedIndex;
if (dropdownSelIndex === 0) {
$w('dropdown2').show();
} else if (dropdownSelIndex === 1) {
$w('dropdown2').hide();
}
});
Each selected index number corresponds the the dropdown's options.