Попробуйте любое из следующих 3:
1-й способ
JAVASCRIPT
function add_event_setup(selectElement) {
var val = selectElement.value;
if(val == "TF")
alert("DO THIS");
else if(val == "JR")
alert("DO THAT");
else
alert("something else"); }
HTML
<select class="formselect" onchange="add_event_setup(this);">
<option value="Game Terms" class="formselect">--Game Terms--</option>
<option value="TF" style="border: 1px solid gray" class="formselect">TimeFrame</option>
<option value="JR" style="border: 1px solid gray" class="formselect">Jim Ross</option>
</select>
2-й способ
HTML + JAVASCRIPT (Убедитесь, что тег сценария размещен после тега select, как показано ниже)
<select id="myform" class="formselect">
<option value="Game Terms" class="formselect">--Game Terms--</option>
<option value="TF" style="border: 1px solid gray" class="formselect">TimeFrame</option>
<option value="JR" style="border: 1px solid gray" class="formselect">Jim Ross</option>
</select>
<script>
document.getElementById("myform").addEventListener("change", function() {
var val = this.value;
if(val == "TF") {
alert("DO THIS");
} else if(val == "JR") {
alert("DO THAT");
} else
alert("something else");
}, false);
</script>
3-й способ
На всякий случай, если вы используете jQuery :
JAVASCRIPT
var MySelector = {
setup : function() {
$('#myform').bind('change', function() {
var val = $(this).val();
if(val == "TF") {
alert("DO THIS");
} else if(val == "JR") {
alert("DO THAT");
} else
alert("something else");
});
}
};
$(document).ready(function() {
MySelector.setup();
});
HTML
<select id="myform" class="formselect">
<option value="Game Terms" class="formselect">--Game Terms--</option>
<option value="TF" style="border: 1px solid gray" class="formselect">TimeFrame</option>
<option value="JR" style="border: 1px solid gray" class="formselect">Jim Ross</option>
</select>