By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 1,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

Javascript Quiz

P: n/a
I need a simple quiz script and have found one at this url
http://www.mompswebdesign.com/jscript/quiz_creator.html which I can adapt
for my own needs. There is one thing I need help on though, I want that if
the score = 100% that either a new page opens or a url link / message is
displayed in the correct answers text area . Any takers?

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
change the function getScore() to detect when score is 100%

if(score=100){topMarks()}

and do what you like with the function

function topMarks(score){
alert("You have scored "+score)
// open a new window
// or
// display some text

}
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);
if(score=100){topMarks(score)}
form.percentage.value = score + "%";
var correctAnswers = "";
for (i=1; i<=numQues; i++) {
correctAnswers += i + ". " + answers[i-1] + "\r\n";
}
form.solutions.value = correctAnswers;
}
// -->

"Hogan" <jh******@hotmail.com> wrote in message
news:bo*************@ID-185826.news.uni-berlin.de...
I need a simple quiz script and have found one at this url
http://www.mompswebdesign.com/jscript/quiz_creator.html which I can adapt
for my own needs. There is one thing I need help on though, I want that if
the score = 100% that either a new page opens or a url link / message is
displayed in the correct answers text area . Any takers?

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.