Reply
Tue 17 May, 2011 02:37 am
function getScore(form) {
var score = 0;
var currElt;
var currSelection;
for (i=0; i<numQues; i++) {
currElt = i*numChoi;
for (j=0; j<numChoi; j++) {
currSelection = form.elements[currElt + j];
if (currSelection.checked) {
if (currSelection.value == answers) {
score++;
break;
}
}
}
}
score = Math.round(score/numQues*100); // math.round function will return the whole number to the nearest specified value for example 1.9 will show as 2
form.percentage.value = score + "%"; // The score will be displayed in percentage
var correctAnswers = "";
for (i=1; i<=numQues; i++) {
correctAnswers += i + ". " + answers[i-1] + "\r\n";
}
form.solutions.value = correctAnswers;
}
@bgurung,
Reading it casually, it seems to be a score keeper of perhaps some sort of quiz that gives score in percentages.
@bgurung,
This is in C Programming Language. It is program to keep the score for quiz or tests.
@talk72000,
That is not C. It is JavaScript. You can tell because the function parameters aren't typed, and there are DOM calls.
@maxdancona,
They are so similar anyways.