You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sae_2a_anglais/Project/php/js/quiz.js

41 lines
1.0 KiB

var currentQuestion = 0;
var score = 0;
function validateAndNext(correct) {
if (correct) score++;
nextQuestion();
}
function nextQuestion() {
var currentQuestionDiv = document.getElementById("question" + currentQuestion);
currentQuestionDiv.style.display = "none";
currentQuestion++;
if (currentQuestion < len) {
var nextQuestionDiv = document.getElementById("question" + currentQuestion);
nextQuestionDiv.style.display = "block";
}
else{
window.location.href = 'resultatsJeux';
var form = document.createElement('form');
form.method = 'post';
form.action = 'resultatsJeux';
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'score';
input.value = score + '/20';
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
}
window.onload = function () {
var firstQuestionDiv = document.getElementById("question0");
firstQuestionDiv.style.display = "block";
};