I created a page with a yes or no question. If you answer yes and hit the submit button it will direct you to enter.html if you hit no and hit the submit button it will direct you to donotenter.html.
For some reason the submit button does not work on a single click. The user has to double click it in order to work. I was not able to find an answer on anyone else's question.
function check() {
var c = 0
var q1 = document.quiz.question1.value;
if (q1 == "Yes") {
document.getElementById("myButton").onclick = function() {
window.location = 'enter.html';
};
} else {
document.getElementById("myButton").onclick = function() {
window.location = 'donotenter.html';
};
}
}
<form name="quiz" id="quiz">
<div>
<p> 1. What is the answer to this question:</p>
<P><input type="radio" name="question1" value="Yes">A. Yes</P>
<P><input type="radio" name="question1" value="No">B. NO</P>
</div>
<input type="button" name="" value="Submit" id="myButton" onclick="check()">
</form>