I have created a quiz within html using various functions. I would like the user to be able to click the 'next page' button, only if they achieve a certain score from the quiz. Any ideas of how I could implement this?
Below is the script I am using. It shows the calculation sum to get a score for their answers as well as a message that corresponds to their score.
The issue I am having I am not sure on how to implement some sort of script that allows the user to click the 'next page' button if they achieve a grade of 75 or above. Any help is much appreciated - a newbie to html
<script>
document.getElementById("form3").onsubmit=function(){
hr = parseInt(document.querySelector('input[name = "hr"]:checked').value);
prevent = parseInt(document.querySelector('input[name = "prevent"]:checked').value);
hmrc = parseInt(document.querySelector('input[name = "hmrc"]:checked').value);
email = parseInt(document.querySelector('input[name = "email"]:checked').value);
paypal = parseInt(document.querySelector('input[name = "paypal"]:checked').value);
result = hr + prevent + hmrc + email + paypal;
document.getElementById("grade").innerHTML = result;
if (result == 0) {result2 = "Not good enough, you could potentially become a victim of social engineering in the future."};
if (result == 25) {result2 = "You need to spend more time. try again."};
if (result == 50) {result2 = "You could do better, try again."};
if (result == 75) {result2 = "Pretty good job."};
if (result == 100) {result2 = "Great Stuff! You clearly understand the dangers of social engineering! "};
document.getElementById("grade2").innerHTML = result2;
return false;
}
</script>
Aucun commentaire:
Enregistrer un commentaire