Redirect with a Dropdown Menu in JavaScript
This simple scripts show a possibility to call a JavaScript function that
retrieves a variable passed from drop down box as a parameter and then the
JavaScript redirects the browser to the variable that was passed to it.
[View All Snippets]
[View All Snippets]
Show Plain Text »
- <script type="text/javascript">
- function do_redirect(site){
- window.location.href = site;
- }
- </script>
- <select onchange="do_redirect(this.value)">
- <option value="#">What site would you like to see?</option>
- <option value="https://www.google.com">Google</option>
- <option value="https://www.yahoo.com">Yahoo</option>
- <option value="https://www.apphp.com">ApPHP</option>
- </select>