Answer to Question #40275 in AJAX | JavaScript | HTML | PHP for Schneizel
2014-03-18T00:03:57-04:00
Quick Quiz var answers = new Array();
answers[0] = "d";
answers[1] = "b";
answers[2] = "a";
answers[3] = "b";
answers[4] = "b";
answers[5] = "c";
answers[6] = "a";
answers[7] = "b";
answers[8] = "b";
answers[9] = "c";
var currentQues = 0;
var numQues = answers.length;
var numChoi = 4;
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[i]) {
score++;
break; }
}
}
}
score = Math.round(score/numQues*100);
form.percentage.value = score;
return false;
}
function validate_form(theForm)
{
var radioSelected = false;
for (i = 0; i < theForm.q1.length; i++)
{
if (theForm.q1[i].checked)
radioSelected = true;
}
if (!radioSelected)
{
alert("Pls answer question No. 1");
return (false);
}
va
0
Answer in progress...
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Comments
Leave a comment