Question/Answer Validation

[Total: 0    Average: 0/5]

This shows how to have a question validated on the submit.

Head Code:

<script language="JavaScript"> 
var result1=0;  
function quiz(form) {        
var _1 =0;          
if (result1 == 1){            
_1 = "Incorrect"             
}         
else         
if (result1 == 2){            
_1 = "Correct" 
}           
document.open();           
document.write("<HTML><BODY><p>Question 1<BR>" + _1 + "</BODY></HTML>");            
document.close();     } 
</script> 

Body Code:

<form name="form1"> 1. Question #1<br> 
<input type="radio" name="one" value="1" onclick="result1='1';"> 1
<br> <input type="radio" name="one" value="2" onclick="result1='2';"> 2
<br> </form> <br> <form name="total"><br> 
<input type="submit" value="Results" onclick="quiz()"> 
</form> 

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *