JavaScript Program to Create Pulldown Menu and After Clicking Open Selected Website

Write a JavaScript program to create pulldown menu and after clicking open selected website.

Write a JavaScript to create a pull – down menu with three options [google, msbte, yahoo] once the user will select one of the options then user will be redirected to that site.



Source Code
<html>
<head>
    <title>Creating Pull-down menu</title>
    <script>
        function gotoWebsite(choice)
        {
            url = choice.options[choice.selectedIndex].value
            if(url != "")
            {
                window.location = url
            }
        }
    </script>
</head>
<body>
<form action="" name="form1">
    Select your favourite website: 
    <select name="website" onchange="gotoWebsite(this)">
        <option value="http://www.google.com">Google</option>
        <option value="http://www.yahoo.com">Yahoo</option>
    <option value="http://www.msbte.org.in">MSBTE</option>
</select>
</form>
</body>
</html>
Output