Javascript Quiz

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hogan

    Javascript Quiz

    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?



  • steve stevo

    #2
    Re: Javascript Quiz

    change the function getScore() to detect when score is 100%

    if(score=100){t opMarks()}

    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(scor e/numQues*100);


    if(score=100){t opMarks(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" <jhogan15@hotma il.com> wrote in message
    news:bo4iv8$17o je8$1@ID-185826.news.uni-berlin.de...[color=blue]
    > 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?
    >
    >
    >[/color]


    Comment

    Working...