Hi there,
You forgot a couple of tags.
This should work.
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
<form name="myform">
<p>What is the correct spelling of this word?</p>
<input type="text" name="q1">
<input type="button" onClick="valid()" value="check answer" />
</form>
<script type="text/javascript">
function valid() {
cor = "0"
incor = "0"
test0 = document.myform.elements[0].value;
test1 = document.myform.elements[1].value;
if (test0.toLowerCase() == "barriers"){
++cor;
}else{
++incor;
}
alert("You are " + cor * 100 + "% correct!");
}
</script>
</body>
</html>
Bookmarks