Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9008891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:03:20+00:00 2026-06-16T02:03:20+00:00

I make a quiz script with jQuery with some questions based on true/false. Each

  • 0

I make a quiz script with jQuery with some questions based on true/false. Each questions has 2 choices. If you select the true answer of choice 1 for question 1, it automatically select the False answer of choice 2 (crosswisely, that’s logical – you can’t answer 2 times to a single question).

With my script, I have a problem, easy to say but more difficult to code : if I click on the True answer of the question 1 two times, my score increases 2 times. Same problem if I select the another answer (False for choice 1 in this case) for the same question. I can choose all answers but this is not logical…

I search to “block” the choices to one “click” for each questions, but I don’t know how. I played with vars but it was not convincing.

quizz = function(){
  vars = {
     score  : 0,
     scroll : 1
  };

  // Scroll to the next question
  q = {
     next: function(which){
        if (vars.scroll === 1){
           $d.scrollTo(which, 500);
        }
     },
     // If good answer is clicked, increase the score
     score: function(which){
        if (which.hasClass("t")){
           vars.score++;
        }
     }
  };
};

// Init the quizz
quizz();

// On questions click
$(".quizz .r").on("click", function(e){
  var $t = $(this),
      $q = $t.closest(".q"),
      q_ans = $t.attr("class").split("r ")[1],
      q_id = $q.attr("id"),
      ac = "active";

  $t.addClass(ac);
  $q.find("."+ q_ans).addClass(ac);
  q.score($t);

  if (q_id == "q7"){
     e.preventDefault();
  } else {
     q.next($q.next());
  }

  $(".result p").html("Score : "+ vars.score);

   e.preventDefault();
});

Here is my try : http://jsfiddle.net/uZQbS/

If you have an idea…
Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:03:22+00:00Added an answer on June 16, 2026 at 2:03 am

    Just found a solution playing with a disable class.

    // On questions click
    $(".quizz .r").on("click", function(e){
        var $t = $(this),
            $q = $t.closest(".q"),
            q_ans = $t.attr("class").split("r ")[1],
            q_id = $q.attr("id"),
            ac = "active";
    
        if ($q.is(":not(.disable)")){
           $t.addClass(ac);
           $q.find("."+ q_ans).addClass(ac);
           $q.addClass("disable");
           q.score($t);
    
           if (q_id == "q7"){
              e.preventDefault();
           } else {
              q.next($q.next());
           }
    
          $(".result p").html("Score : "+ vars.score);
       }
    
       e.preventDefault();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to make multiple quizes that will keep track of each quiz on
i am trying 2 make a quiz in asp.net. the mcq choices r displayed
I have created a form that allows users to make a multiple choice quiz.
I am trying to make a quiz that should show questions not answered before
I am making a quiz application with question and answer. I want to make
I want to make an quiz wizard using jQuery. Here is the link which
I want make some quizes about movie. There is quiz mutable array with 10
I'm making a simple quiz database, where a question has an answer and one
Hey I'm writing a quiz application for android. Some of the questions asked require
I want to make a quiz and the user should type the right answer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.