#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 1999
    Posts
    9
    Rep Power
    0
    I'm trying to figure out how to score a quizz using wmlscript. I have the correct/incorrect answer part working, I'm trying to create a function that keeps score by incrementing the value of a variable, I'm not sure what I'm doing wrong.

    the script:

    function addscore(){
    var points;
    points=points++;
    return points;
    }

    extern function validateAnswer(Answer)
    {
    var validResponse = WMLBrowser.getVar("Answer");
    if (validResponse != "value")
    {
    WMLBrowser.go("poll2.wml#NResults");
    }
    else
    {
    WMLBrowser.go("poll2.wml#YResults1");
    var number = addscore();
    WMLBrowser.setVar("score", number);
    }
    };

    extern function validateAnswer2(Answer){
    var validResponse = WMLBrowser.getVar("Answer");
    if (validResponse != "value")
    {
    WMLBrowser.go("poll2.wml#NResults");
    }
    else
    {
    WMLBrowser.go("poll2.wml#YResults3");
    var number = addscore();
    WMLBrowser.setVar("score", number);
    }
    };

    The card that's supposed to show the score:

    <card id="YResults3" title="Results:">
    <p>
    Yes: Answer $(Answer) is correct "
    </p>
    <p>
    Score: $(score) out of 3 "
    </p>
    <p>
    <a href="poll2.wml#Trivia1">Start Over</a>
    </p>
    </card>
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    9
    Rep Power
    0
    I would make sure of two things:

    (1) That you have the correct initial value of points in the addscore function, and

    (2) That you are calling the addscore function before you go to the YResults3 card.

IMN logo majestic logo threadwatch logo seochat tools logo