www.webdeveloper.com
Results 1 to 2 of 2

Thread: moving arrays and variables expert

  1. #1
    Join Date
    Jul 2013
    Posts
    24

    moving arrays and variables expert

    Hey guys this code here checks the answers to a quiz .
    this first line of code displays a alert for each question saying "you got question #1 right" then the same thing for 2 and every other question you got right.
    How can I store each question into a variable?

    For example. *Variable "question1" = "what is 1+1?" *user answered 3, correct answer was 2

    More information--I am making a quiz... *it has around 100 questions in a array. *It randomly picks 10 questions in an array each time the quiz is taken. *I want the review page of the quiz to display those same 10 questions and what the user chose for answers.
    I have already moved the variable "score" to the new page but cant get any further then that
    Any help would be greatly appreciated.


    Code:
    Ix = Ix+1
    alert("you got question # " + Ix + " correct");
    Ix = Ix-1

    Code:
    else {
    for (var Ix=0; Ix<10; Ix++) {
    if (this.Answer[Ix] == this.thisAns[Ix]) {
    document.getElementById("check" + Ix).checked = true;
    score++;
    Ix = Ix+1
    alert("you got question # " + Ix + " correct");
    Ix = Ix-1
    totalscore = score
    } else {
    document.getElementById("check" + Ix).checked = false;

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415
    It takes a lot less time to show you what to fix
    than it takes to design and develop your code from scratch.

    Show all pertinent code. HTML, JS and CSS, if applicable.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles