Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Last active April 13, 2017 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikestratton/610ec41b616e4f6a4b9a4e2b2e1be05d to your computer and use it in GitHub Desktop.
Save mikestratton/610ec41b616e4f6a4b9a4e2b2e1be05d to your computer and use it in GitHub Desktop.
/** https://github.com/mikestratton/jquery-quiz **/
for(var i = 1; i <= 45; i++) { // loop radio buttons
var radios = document.getElementsByName('q'+i); //used to increment questions in html
for(var j = 0; j < radios.length; j++) {
var radio = radios[j];
if(radio.value == "1" && radio.checked) {
amountCorrect = amountCorrect + 1; //add radio value to total
}
}
}
if(amountCorrect <= 30) {
document.getElementById("total").innerHTML = "Your Score: " + amountCorrect;
document.getElementById("results").innerHTML = "<strong>Your message here</strong>"; //send to html
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment