You can use the onchange
event of the select
:
Step 1:
<script>
function redirectChange() {
var newUrl = this.options[this.selectedIndex].value;
document.location.href = "http://www.yourbaseurl.com/" + newUrl;
}
</script>
Step 2 - Option 1:
After the function hook up the event using addEventListener
(I prefer this way as it allows chaining - notice you must add an html id
to the select
)
<script>
document.getElementById("<insert your select id").addEventListener("change",redirectChange,false);
</script>
Step2 - Option 2:
Or change the html with direct onchange
event hooking (I prefer the previous)
<form action="...">
<select name="name" onchange="redirectChange(this)>
<option value="option1.php">Option 1</option>
<option value="option2.php">Option 2</option>
</select>
</form>
Working jsFiddle:
http://jsfiddle.net/mapVz/1/