Skip to content
Advertisement

Javascript quiz with multiple radio and text input types

I’ve made a small test/quiz with radio and checkbox types. Radio button in my code is mandatory to be checked and when it is, I get the total score for all correct answers, when it’s not I get alert message that i need to check all questions.

Now I want to expand this quiz.

1st problem: I’ve made multiple radio type questions, I don’t know how to check if all radio type questions are checked.

2nd problem: I’ve made test type questions and I want them to be seen after I push “Finish” (alongside total score from test questions), but when I push “Finish” I do not see the text type answers.

JavaScript
JavaScript

Advertisement

Answer

I figured it out myself. I added few lines where for checked answer in every question the “filledQuestion” score increases by 1. Then if “filledQuestion” score is equal to the number of questions, it passes, if not, it shows error message.

JavaScript

My second issue was due to my choice to use ( exam.style.display=”none”; ) line. When i do not use it, the score is visible in the same page and therefore i can see all the changes after i submit the form.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement