Vote count:
0
So I'm creating a simple 1 question multiple choice quiz and depending on the answer submitted I want it to redirect the user to a corresponding page. However, my problem is that no matter what input I submit I'm directed to the same page even if I submit the correct answer. Can someone scan through my code to see if maybe its a slight syntax error that I'm missing.
Code:
<!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.0 Strict//EN"
"http://ift.tt/1wyXNZE">
<html>
<head>
<title>International Business</title>
<style type="text/css">
.myIndent{
margin-left: 2em;}
</style>
<script type="text/javascript">
function submitQuestion(){
var response = document.getElementById('answer').value;
if (response == 'C'){
location="correct.html";
}
else{
location="wrong.html";
}
return false;
}
</script>
</head>
<body>
<form>
<p>31.) As long as international businesses _________, Islamic countries are likely to be receptive to those businesses.</p>
<div class="myIndent">
<labe>A.)<input type="radio" name="answer" id="answer" value="A">employ Muslim people</label><br />
<label>B.)<input type="radio" name="answer" id="answer" value="B">have property in an Islamic nation<label><br />
<label>C.)<input type="radio" name="answer" id="answer" value="C">behave in a manner that is consistent with Islamic ethics</label><br />
<label>D.)<input type="radio" name="answer" id="answer" value="D">adhere to Islamic beliefs</label><br />
</div>
<br /><br />
<input type="submit" value="Submit" onclick="return submitQuestion()">
<input type="reset" value="Cancel">
</form>
</body>
</html>
asked 2 mins ago
Javascript redirecting to wrong page
Aucun commentaire:
Enregistrer un commentaire