Skip to content

Instantly share code, notes, and snippets.

@jordic
Created May 10, 2012 07:27
Show Gist options
  • Save jordic/2651676 to your computer and use it in GitHub Desktop.
Save jordic/2651676 to your computer and use it in GitHub Desktop.
JS select dinamic
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$('#menu').change(function(){
if( $(this).val() == "0")
return
window.location.href = $(this).val()
});
});
</script>
</head>
<body>
<select id="menu">
<option value="0">Selecciona la dirección</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.yahoo.com">Yahoo</option>
</select>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment