Posted By

apphp-snippets on 03/05/13


Tagged

javascript redirect


Versions (?)

Redirect with a Dropdown Menu in JavaScript


 / Published in: JavaScript
 

URL: http://www.apphp.com/index.php?snippet=javascript-redirect-with-dropdown-menu

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.

  1. <script type="text/javascript">
  2. function do_redirect(site){
  3. window.location.href = site;
  4. }
  5. </script>
  6.  
  7. <select onchange="do_redirect(this.value)">
  8. <option value="#">What site would you like to see?</option>
  9. <option value="http://www.google.com">Google</option>
  10. <option value="http://www.yahoo.com">Yahoo</option>
  11. <option value="http://www.apphp.com">ApPHP</option>
  12. </select>

Report this snippet  

You need to login to post a comment.