[Javascript] Quiz Script Mac IE 5.22 Problem

Humberto T. Reyes htreyes at earthlink.net
Tue Oct 28 13:56:48 CST 2003


Greetings,

I am currently using a script for a training quiz below--the problem I 
am having is that on IE 5.22 It always provides the incorrect alert, 
even if the answer id correct.  The answer is collected as a variable 
from the form that submits to this script.

Does anyone see anything wrong with this script?  Any ideas.

Thanks in advance.

Humberto

-------------JavaScript-------------
function exam(examform, next) {
	var noquizckbx = document.getElementsByName('noquiz')[0];
	if (noquizckbx) {
		if (noquizckbx.checked) {next = next + '&noquiz=1'}
	}
if(answer.length == 0) {
document.location.href = next;
return;
} else {
newgrade = new Array(answer.length);
for (i=0; i<examform.elements.length; i++) {
formvar = examform.elements[i];
if(answer[formvar.name]) {
if (formvar.checked) {
if (formvar.value == answer[formvar.name]) {
newgrade[formvar.name]=1;
}
}
} else {
if (!formvar.checked) {
newgrade[formvar.name]=1;
}
}
}
incorrect = 0;
for (i=1; i<newgrade.length; i++) {
if(!newgrade[i]) {
incorrect = 1;
}
}
if (incorrect==0) {
//   alert('Correct.  Continuing to next page');
document.location.href = next;
} else {
alert('Incorrect.  Please try another answer');
}
}
}

function answerquiz(examform) {
if(answer.length) {
for (i=0; i<examform.elements.length; i++) {
formvar = examform.elements[i];
if(answer[formvar.name]) {
//		alert('here:'+formvar.name+formvar.value+'='+answer[formvar.name]);
				if (formvar.value == answer[formvar.name]) {
					formvar.checked = 1;
	    formvar.value = answer[formvar.name];
				}
			}
		}
	}
}

--------end JavaScript ----------




More information about the Javascript mailing list