How to make a quiz of a page using javascript? [closed]

-2

How to make a quiz in JavaScript using the checkbox or html radio?

    
asked by anonymous 03.02.2018 / 14:49

1 answer

1

Man, this is something very open, but I'll give you some ideas for you to have a base.

Using javascript only

You can use a global variable called pontos

And with the interface already mounted you would show the questions and when the user selected a response, you would do a check in onclick .

This check would be basically (if the user selected A and A is correct, then the global variable points is summed with the amount of points worth the question.

ex: pontos += 30;

After this the interface would show another question, these questions could be in an array and this array would mount the html structure where the question is, eg:

//pergunta 1
array[1] = '<div><p>Pergunta1</p></div>
               <div><p>resposta A</p></div>
               <div><p>resposta B</p></div>
               <div><p>resposta C</p></div>';

//pergunta 2 
array[1] = '<div><p>Pergunta1</p></div>
               <div><p>resposta A</p></div>
               <div><p>resposta B</p></div>
               <div><p>resposta C</p></div>';

and in the% w_that you would do the events, when html in the ok button, check if it acted, hit it or make a mistake change the array to the next index (next question). It ends when you get to the end of the array;

When you finished the questions it would show the variable points that would be the amount you hit

But what's the problem with just using Javascript?

Remembering that it would be interesting to use a backend language to connect to the database and store your data.

Basically to get something cool you will use CSS, JS, HTML5, a database, and a backend language (I recommend PHP).

    
03.02.2018 / 16:13