Good afternoon,
I’m trying to set up a dropdown menu in my website’s banner that links to different websites.
I’m using the code below, however, when clicking on the dopdown no options are shown (“dropdown doesn’t drop”). May anyone give a hint?
Thanks :),
Constantin
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#dropdown1").options = [
{"Label": "Deutsch", "Value": "http://vanthunder.com"},
];
});
export function userProfileDropdown_change(event)
{
let page = event.target.value; // new page name selected
let path = page; // create path to local page
wixLocation.to(path);
}
Hi,
I think the problem is that “label” and “value” keys supposed to begin with small letter.
If it still not working please send us a URL to your site.
Best,
Sapir
Spot on
https://www.wix.com/corvid/reference/$w.Dropdown.html#options
Set the list of options for a dropdown
$w("#myDropdown").options = [
{"label": "Who's on first!", "value": "first"},
{"label": "What's on second", "value": "second"},
{"label": "I Don't Know is on third", "value": "third"}
];
Make sure that your dropdown element that you are setting the options for is the same name as your dropdown element that you have used in the onChange event handler function.
As currently you have the options for #dropdown1 , whereas your onChange event is for a dropdown called #userProfileDropdown .
The easiest option here is to put the url address in as the value of the dropddown choice and have ‘Deutsch’ as the label.
If you still want to set the dropdown options then read on.
So, as Sapir states, change the label and value to lowercase and make sure that the dropdown id names match.
Also, make sure that you do not have any default dropdown choices in the dropdown settings itself, this needs to be blank to show your own options.
Both options will give you this and it will then take you to the url of:
https://www.vanthunder.com/