I am receiving an alert if I select an option after I have already selected one but not for the option I select first. Im not sure why I am not receiving an alert the first time I select an option. I know I haven't worded it well but its a tricky one to word! Here is my code :
HTML
<select id="button1" class="button" title="Button 1" onchange="getDropDownVal()">
<option value="0">--Please choose an option for the first blank--</option>
<option id="buttonText1_1" class="buttonText" value="1">Banana</option>
<option id="buttonText1_2" class="buttonText" value="2">Apple</option>
<option id="buttonText1_3" class="buttonText" value="3">Grape</option>
<option id="buttonText1_4" class="buttonText" value="4">Peach</option>
<option id="buttonText1_5" class="buttonText" value="5">Melon</option>
<option id="buttonText1_6" class="buttonText" value="6">Pineapple</option>
</select>
JS
function getDropDownVal() {
document.getElementById("button1").onchange = function() {
alert(this.value);
return false;
}
}
Here is my code in a Fiddle but this doesn't seem to show an alert at all?
Thanks in advance.