I've written a dropdown menu that I want functions to fire when an option is clicked. It hasn't been working on any browser so I replaced the first function with a simple alert but that's not firing either. Any pointers would be appreciated!
<select name="webmenu" id="webmenu">
<option value="UK" id="UK_button" title="assets/images/uk_flag.png" onclick="alert('You are clicking on me');"> </option>
<option value="US" id="US_button" title="assets/images/us_flag.png" onclick="finalResultsUS()"> </option>
<option value="EU" id="EU_button" title="assets/images/euro_flag.png" onclick="finalResultsEuro()"> </option>
</select>
I've made a few changes to the code based on replies so far (thanks guys)
<select name="webmenu" id="webmenu">
<option value="UK" id="UK_button" title="assets/images/uk_flag.png" onchange="alert('You are clicking on me');"> </option>
<option value="US" id="US_button" title="assets/images/us_flag.png" onchange="finalResultsUS()"> </option>
<option value="EU" id="EU_button" title="assets/images/euro_flag.png" onclick="finalResultsEuro()"> </option>
</select>
<script>
document.getElementById("webmenu").onchange = function() {alert('you clicked me');
}
</script>
but I need a to be able to fire off a different function for each specific choice rather than one function for any change in selection. How could I do this without jquery please?
I could use:
document.getElementById("webmenu").onchange = function() {
alert(this.value)
return false
};
but how would I write it so that clicking on the US option (2nd option) would trigger the US function for example rather than just firing off alerts please?