
Formative Test Form
By: a guest on
Mar 19th, 2012 | syntax:
HTML | size: 0.92 KB | hits: 26 | expires: Never
<SCRIPT language="JavaScript" type="text/javascript">
function checkFormativeTest(testForm, rightAnswer)
{
var choice;
for(i = 0;i<testForm.elements.length;i++)
{
if(testForm.elements[i].checked)
{
choice = testForm.elements[i].value;
}
}
switch(choice)
{
case undefined:
alert("Please make a selection.");
break;
case rightAnswer:
alert("'"+choice+"' is correct!");
break;
default:
alert("'"+choice+"' is incorrect.");
}
return false;
}
</SCRIPT>
------------------------------------------------------------------------
Question?
<form method="POST" onSubmit="return checkFormativeTest(this,'B');">
<input type="radio" value="A" name="">
A. Answer A
<input type="radio" value="B" name="">
B. Answer B
<input type="radio" value="C" name="">
C. Answer C
<input type="submit" value="Submit Answer">
</form>