function calculateScore() { var score = 0; var theForm = document.getElementById("questionnaire"); var theResult = document.getElementById("results"); var theResultMsg = document.getElementById("results_msg"); var theButton = document.getElementById("scorebtn"); for (var i = 0; i < 20; i++) { var theQ = "q" + i; var radioGrp = theForm.elements[theQ]; var answered = false; for (var j = 0; j < radioGrp.length; j++) { if (radioGrp[j].checked) { score += parseInt(radioGrp[j].value); answered = true; } } if (answered == false) { alert("Oops, you forgot to answer Question " + (i + 1) + "."); return; } } if (score >= 24) theResultMsg.innerHTML = "Your score is " + score + ". You're doing great!"; else theResultMsg.innerHTML = "Your score is " + score + ". Consider Personal Impact Guide to Minding Your Manners in Everyday Matters or a Session with Personal Impact to develop your potential!"; theResult.style.visibility = "visible"; theButton.disabled = true; for (var i = 0; i < 20; i++) { var theQ = "q" + i; var radioGrp = theForm.elements[theQ]; for (var j = 0; j < radioGrp.length; j++) radioGrp[j].disabled = true; } return; }