DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chara has posted 50 posts at DZone. View Full User Profile

Redirect with a Dropdown Menu in JavaScript

  • submit to reddit
<!-- source: -->
<script type="text/javascript">
function do_redirect(site){
   window.location.href = site;
<select onchange="do_redirect(this.value)">
   <option value="#">What site would you like to see?</option>
   <option value="">Google</option>
   <option value="">Yahoo</option>
   <option value="">ApPHP</option>

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.


Dan Rios replied on Wed, 2013/02/13 - 12:06am