I hope someone can help I have a HTML form with 10 number input fields with class="takings". I want to attach a JS function ideally to the onchange event of each, but I'd settle for onmouseup or similar if I had to. the following is called from an external js file:
function init(){
var input = document.getElementsByClassName("takings");
for (var i = 0; i < input.length; i++) {
input[i].onchange = function()
{
alert('testing');
}
input[i].value = 0.00;
}
}
window.onload=init;
I have tested this code on firefox and chrome and it works fine. It does not however work on IE (I have tested IE8 and IE11 so far). I need to have this app run in IE as it is the only browser we use on our company network. Due to other dependencies changing it is not even an option. It did briefly occur to me that we may have some group policy in place blocking some browser functionality but the same behaviour occurs outside of our domain. Can anyone tell me where I'm going wrong or a way to achieve equivalent functionality on IE?
Thanks very much
*****UPDATE**********
function init(){
var input = document.querySelectorAll(".takings");
for (var i = 0; i < input.length; i++) {
input[i].attachEvent("onchange", function () {alert('testing');});
input[i].value = 0.00;
}
}
This code works only on ie8 and not ff or ie11