The quiz is written using vanilla Javascript and HTML:
<div class="quiz-container" id="quiz">
<div class="quiz-header">
<p>Please make sure to <a href="#">read the rules</a></p>
<h1>Quiz</p>
<h2 id="question">Question Text</h2>
<ul>
<li>
<input type="radio" name="answer" id="a" class="answer">
<label for="a" id="a_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="b" class="answer">
<label for="b" id="b_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="c" class="answer">
<label for="c" id="c_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="d" class="answer">
<label for="d" id="d_text">Answer</label>
</li>
</ul>
</div>
<button id="submit">Next</button>
</div>
At the end of the quiz, the results are shows to the user:
submitBtn.addEventListener('click', () => {
const answer = getSelected()
if(answer) {
if(answer === quizData[currentQuiz].correct) {
score++
}
currentQuiz++
if(currentQuiz < quizData.length) {
loadQuiz()
} else {
quiz.innerHTML = `
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<input class="btn" type="button" onclick="window.open('mailto:email@email');" value="Submit results" />
`
}
}
What is the best way to possibly submit these answers to a backend? I know Javascript can’t blind submit results using mailto: as it’s client side, so any suggestions would be amazing.