Redirect with a Dropdown Menu in JavaScript

/ Published in: JavaScript
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. function do_redirect(site){
  3. window.location.href = site;
  4. }
  5. </script>
  7. <select onchange="do_redirect(this.value)">
  8. <option value="#">What site would you like to see?</option>
  9. <option value="">Google</option>
  10. <option value="">Yahoo</option>
  11. <option value="">ApPHP</option>
  12. </select>


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.