It is saying as 'Uncaught ReferenceError: go is not defined' because the go() method is wrapped in onload. Change the wrap option to body, then it will work.
Select tag and go to page option
-
04-10-2022 - |
Question
Can anyone explain why below example does not work? I'd like to impelment dropdown that will redirect to other sites based on the option selected.
function go()
{
window.location=document.getElementById("menu-dropdown").value;
}
Solution
OTHER TIPS
In the Frameworks & Extensions panel
, set onLoad to No wrap - in <body>
.it will work
Without a separate function
<select id="mySelect" onChange="document.location = this.value" value="GO">
<option>Select</option>
<option value="http://www.microsoft.com">Test</option>
</select>
You have an error in redirecting the page. It is
window.location.href="";
your code is right only thing you have move your go function inside body I updated your code in jsfiddle.
jsfiddle.net/mannejkumar/5swk8/11/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow