Hopefully this is quite a simple question for someone to answer as I have been searching endlessly to no avail
I want to design a simple online test using JavaScript Validation
I have started with the following code
<html>
<head>
</head>
<body>
<h1> What colour is blue </h1>
<script LANGUcolour="JavaScript">
<!--
function ValidateForm(form){
ErrorText= "";
if ( form.colour.selectedIndex == 0 ) { alert ( "Please Select an option" ); return false;
}
if ( form.colour.selectedIndex == 1 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 2 ) { alert ( "Congratulations You May Proceed" ); return true;
}
if ( form.colour.selectedIndex == 3 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 4 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 5 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if (ErrorText= "") { form.submit() }
}
-->
</script>
<br><form name="feedback" action="mailto:me@emailaddress.com" method=post>
Your Answer:
<select name="colour"> <option value="">Please Select an Option:</option>
<option value="black">black</option>
<option value="blue">blue</option>
<option value="yellow">yellow</option>
<option value="red">red</option>
<option value="green">green</option> </select>
<input type="button" name="SubmitButton" value="Check Answers" onClick="ValidateForm(this.form)">
<input type="reset" value="Reset">
</form>
</body>
</html>
Basically when the correct answer is entered in this case blue not only do I want the message window to open, I either want to open a new html page with a different question or make another question visible (whichever is easier/ preferably both if it is a long test). The post function is not essential at this stage but would be nice if I got emails advising me of incorrect or correct answers. I was playing around with adding something like form action="next.html" method="OPEN" to the validation statement when it returns a correct answer.
Obviously when an incorrect answer is given then the person cannot proceed until the correct answer is entered
If anyone can help me out it would be greatly appreciated as I said have been having a bit of trouble working out how to do this. Thank you in advance to all of you that endeavor to try and help me out on this one
Thank you
I want to design a simple online test using JavaScript Validation
I have started with the following code
<html>
<head>
</head>
<body>
<h1> What colour is blue </h1>
<script LANGUcolour="JavaScript">
<!--
function ValidateForm(form){
ErrorText= "";
if ( form.colour.selectedIndex == 0 ) { alert ( "Please Select an option" ); return false;
}
if ( form.colour.selectedIndex == 1 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 2 ) { alert ( "Congratulations You May Proceed" ); return true;
}
if ( form.colour.selectedIndex == 3 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 4 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if ( form.colour.selectedIndex == 5 ) { alert ( "That is Incorrect, Try Again" ); return false;
}
if (ErrorText= "") { form.submit() }
}
-->
</script>
<br><form name="feedback" action="mailto:me@emailaddress.com" method=post>
Your Answer:
<select name="colour"> <option value="">Please Select an Option:</option>
<option value="black">black</option>
<option value="blue">blue</option>
<option value="yellow">yellow</option>
<option value="red">red</option>
<option value="green">green</option> </select>
<input type="button" name="SubmitButton" value="Check Answers" onClick="ValidateForm(this.form)">
<input type="reset" value="Reset">
</form>
</body>
</html>
Basically when the correct answer is entered in this case blue not only do I want the message window to open, I either want to open a new html page with a different question or make another question visible (whichever is easier/ preferably both if it is a long test). The post function is not essential at this stage but would be nice if I got emails advising me of incorrect or correct answers. I was playing around with adding something like form action="next.html" method="OPEN" to the validation statement when it returns a correct answer.
Obviously when an incorrect answer is given then the person cannot proceed until the correct answer is entered
If anyone can help me out it would be greatly appreciated as I said have been having a bit of trouble working out how to do this. Thank you in advance to all of you that endeavor to try and help me out on this one
Thank you