-2
How to do a Javascript quiz using html checkbox or radio?
-2
How to do a Javascript quiz using html checkbox or radio?
1
Man this is something very open, but I’ll give you some ideas for you to have a basis.
Using javascript only
You can use a global variable called pontos
And with the already assembled interface you would show the questions and when the user selected an answer, you would do a check on onclick
.
this check would be basically (if user selected A
and A
is the correct, so the global variable points is summed with the amount of points worth the question.
ex: pontos += 30;
after that 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, e.g.:
//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 html
you would do the events, when clickar
in the ok button, check if you have scratched, hit or miss change the array to the next index (next question). It ends when you reach the end of the array;
When the questions were finished he would show the variable points that would be the amount you hit
But what’s the problem of using Javascript only?
Remembering that it would be interesting for you to use a back-end 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 back-end language (I recommend PHP).
Vlw, you already gave me a north.
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.
Do you have anything ready? The site is for questions of programming. Have any questions?
– Phelipe
I’m still building, but I’m doubting how I’ll do it, but thanks for the help. I’ll try to assemble and then put here with the code.
– Vitor Ferreira