View Single Post
Old 11-08-2012, 11:19 PM   PM User | #1
Ngene
New to the CF scene

 
Join Date: Nov 2012
Location: Nigeria
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Ngene is an unknown quantity at this point
Thumbs up I need help with this Javascript function please

Please help me out, i need help with this code.I attached this function to the on-click event of a button I need it to automatically write a new question to the page after checking the answer of the previous question, without reloading the page.I need it to loop continuously to the end of the questions array. Please help me out.

[CODE]
function buttonCheckQ_onclick()
{
var answer = 0;
while (document.QuestionForm.radQuestionChoice[answer].checked != true)
{
answer++;
}
answer = String.fromCharCode(65 + answer);
if (answerCorrect (questionNumber, answer) == true)
{
alert("Right answer");
}
else
{
alert("Wrong answer. " + answers[questionNumber] + " is the right answer.");
}
for (var qCounter = 0;qCounter < questions.length; qCounter++)
{
document.getElementById('questionDisplay').innerHTML = "";
QuestionFormDisplay()
window.location.reload()
}
}
[CODE]
Ngene is offline   Reply With Quote