I have a select tag that is generated by a php file that I would rather not have to change if it can be avoided. I also do not have the ability to use jQuery to solve my problem. So here is how I am trying to set an onchange event:
var d = document.getElementById('lang_choice');
d.onchange = function(){
window.alert(this.value);
}
The pop up box just says undefined. I have checked the html and it has the value attributes set in the option tags. So I am guessing I misunderstand something about this system and some explanation would be great.
var d = document.getElementById('lang_choice');
d.onchange = function(){
window.alert(this.options[this.selectedIndex].value);
}
It works in older browser.
Although your method should work. There must be error elsewhere in your code. Check console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With