I have a simple HTML personality quiz, with a Javascript function for a set of radio buttons. I want to compute a score based on the numerical values of the responses to the “I see myself” questions; like an addition or a mean in a PHP script.
<script language="JavaScript1.2">
function writequestion(txt, qno)
{
document.write("<li><b> ... " + txt + "</b><br>")
document.write("Disagree")
document.write("  <input type=radio name=question[" + qno + "] value=1 checked>1")
for (i=2; i<=5; i++) {
document.write("  <input type=radio name=question[" + qno + "] value=" + i + ">" + i)
}
document.write("  Agree")
}
writequestion("is talkative", 1)
writequestion("does a thorough job", 2)
writequestion("is original, comes up with new ideas", 3)
writequestion("is helpful, unselfish with others", 4)
</script>
Comments
Leave a comment