due to layout reasons I needed to write a routine that checks if at least one checkbox is checked on a specific form (in typo3). The routine also handles diff. languages so it can be translated...
But somehow IE (I tried with IE11) throws a null reference error when this line is reached (but in Firefox it works perfectly):
if (elems[i].children[0].control['checked'] === true
here is the whole routine:
if(document.getElementById("pollFR") != null && document.getElementById("pollFR") != '' ){
document.getElementById("pollFR").addEventListener("submit", submitCheckboxHandler);
language = "FR"
}
//some more identical if-statements, because there is a form for every //language e.g. pollEN, etc.
function submitCheckboxHandler(ev) {
var elems = document.getElementsByClassName('form-check');
var elemCounter = 0;
var i;
for (i = 0; i < elems.length; i++) {
if (elems[i].children[0].control['checked'] === true)
elemCounter++;
};
if (elemCounter === 0) {
switch(language){
case "EN":
alert("Please choose at least one parameter!");
break;
case "FR":
alert("...french...");
default:
alert("...german...");
}
ev.preventDefault();
}
}
Does anyone know why this happens ?
Thanks !
Aucun commentaire:
Enregistrer un commentaire