the value of the property is null or undefined, not a Function object

34
May 23, 2019, at 07:40 AM

I have code which functions perfectly fine in Chrome and Firefox but IE 11 (where the code MUST function) throws the following error:

The value of the property 'displayquestion' is null or undefined, not a Function object

<div class="questionholder" id="question0" style="display:block"> 
    <a class="text2button" onclick="displayquestion(1,1)">Start / Commencer</a> 
</div> 
 
<script type="text/javascript"> 
function displayquestion(a, ignore, hide) { 
var b = a - 1; 
 
if (hide !== null && hide !== 'hide') { 
// Check if question should ignore inputs 
	if (ignore == 1) { // yes, ignore the inputs so move on to next question 
		showNext(); 
	} else { //no, don't ignore the inputs 
		var input = document.querySelector('input.input' + b); 
		var inputsArray = Array.from(document.querySelectorAll('input.input' + b)); 
		var isValid = inputsArray.every(function(el){ 
			return el.value; // empty string is false 
		}); 
 
		if (input.type == "radio") { //this is a radio input 
			if (document.querySelector("#question" + b + " input[type=radio]:checked")) { //a radio option is selected 
				showNext(); 
			} else { // no radio option is selected so show error 
				showRequired.style.display = "block"; 
			} 
		} else if (input.type == "checkbox") { //this is a radio input 
			if (document.querySelector("#question" + b + " input[type=checkbox]:checked")) { //a radio option is selected 
				showNext(); 
			} else { // no radio option is selected so show error 
				showRequired.style.display = "block"; 
			} 
		} else { // not a radio or checkbox input 
			if (isValid) { //All inputs are filled in 
				showNext(); 
			} else { //inputs are missing! 
				showRequired.style.display = "block"; 
			} 
		} 
	} 
} else { 
	if (ignore == 1) { // yes, ignore the inputs so move on to next question 
		hideQuestions(); 
 
		isIDadmissible = IDadmissible(); 
 
		if (isIDadmissible !== null || isIDadmissible !== undefined || isIDadmissible !== ''){ 
			showResult(); 
		} 
	} else { 
		var inputsArray = Array.from(document.querySelectorAll('input.input' + a)); 
		var isValid = inputsArray.every(function(el){ 
			return el.value; // empty string is false 
		}); 
 
		if (isValid) { //All inputs are filled in 
			hideQuestions(); 
 
			isIDadmissible = IDadmissible(); 
 
			if (isIDadmissible !== null || isIDadmissible !== undefined || isIDadmissible !== ''){ 
				showResult(); 
			} 
		} else { //inputs are missing! 
			showRequired.style.display = "block"; 
		} 
	} 
} 
 
function showNext() { 
	showRequired.style.display = "none"; 
 
	for (var i = 0; i < questions.length; i++) { 
		questions[i].style.display = "none"; 
	} 
 
	var nextQuestion = document.getElementById("question" + a); 
 
	if (nextQuestion !== null) { 
		nextQuestion.style.display = "inline-block"; 
	} 
} 
} 
</script>

The above code displays a html button that when clicked, executes the function displayquestion.

As stated, this works perfectly fine in chrome and firefox with ZERO ERRORS, yet IE11, despite also showing no errors, will throw the error when the button is clicked.

How can this be resolved?

READ ALSO
How to access global data in material-ui MenuItem onClick function

How to access global data in material-ui MenuItem onClick function

I have a list of items and each of them has a menu (material-ui Menu) with option (MenuItem) to edit and delete;

32
Javascript Switch-Case syntax is confusing me [duplicate]

Javascript Switch-Case syntax is confusing me [duplicate]

This question already has an answer here:

57
How do we make an elliptic terrain with matter.js?

How do we make an elliptic terrain with matter.js?

I am trying to use matterjs in order to make an elliptic terrain which can have many bodies in it

61