Skip to content

Instantly share code, notes, and snippets.

@tilhom
Created November 6, 2018 16:23
Show Gist options
  • Save tilhom/47943956b6d21271edeb7330c2f8f17c to your computer and use it in GitHub Desktop.
Save tilhom/47943956b6d21271edeb7330c2f8f17c to your computer and use it in GitHub Desktop.
script
function submitAnswers() {
var score = 0, total = 5;
var q1 = document.forms["quizForm"]["q1"].value;
var q2 = document.forms["quizForm"]["q2"].value;
var q3 = document.forms["quizForm"]["q3"].value;
var q4 = document.forms["quizForm"]["q4"].value;
var q5 = document.forms["quizForm"]["q5"].value;
console.log(q1,q2,q3,q4,q5);
// Validation
for(i = 1; i <= total;i++){
if(eval('q'+i) == null || eval('q'+i) == ''){
alert('You missed question '+ i);
return false;
}
}
alert('Ваш результат '+score+' из ' +total + ' вопросов');
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment