Storing answers to a quiz with javascript

Asked

Viewed 798 times

0

I am trying to create a quiz and would like to know how I create a function to store the answers using javascript. I can store in an array and then compare if they are right?

<!DOCTYPE html>
<html>
  <head>
    <title>Quiz</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <script type="text/javascript" src="script.js"></script>
  <body>
    <form class="formulario">
      <div class="question">
        <p>Quem foi o campeão brasileiro de 2016?</p>
        <input type="radio" name="choice" value="1" id="op1">Palmeiras<br>
        <input type="radio" name="choice" value="4" id="op2">Flamengo<br>
        <input type="radio" name="choice" value="2" id="op3">Grêmio<br>
        <input type="radio" name="choice" value="3" id="op4">Cruzeiro<br><br>
        <input type="submit" value="Enviar">
      </div>
    </form>
  </body>
</html>

  • Where do the questions come from? you are loading a question per page or are using ajax?

  • I want it to be one question per page, but first I need to know how to store the answers. In the case of the code I posted, which function to use to store the answer and check if it is correct?

  • What language do you have on the server? and do you know what ajax and json is?

  • I am asking questions to better understand the context of the application and to be able to give a more useful answer.

  • I’m using javascript only, and I don’t know ajax and json yet.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.