*you missed the '(' and '}'
*Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead. use getElementById instead of q1.r1.value
*your form name is same as radio name, don't do that
below are correct one
Code:
<html>
<head>
<script type="text/javascript">
function getRadio(f, n){
f = document.forms[f].elements;
for (var i = f.length - 1; i > -1; --i)
if(f[i].name == n && f[i].checked)
return f[i].value;
return 'undefined';
}
function CheckCheckbox() {
if (getRadio('q1', 'r1')!= 'counterfeit'){
top.frames["feedback"].location = "correct1.html";
//alert('true');
}
else{
top.frames["feedback"].location = "incorrect1.html";
//alert('wrong');
}
}
</script>
</head>
<body>
<form name="q1">
Jenny thought the <b>fake</b> purse looked just like the real thing!
<br>
<br>
<br>
<input type="radio" name="r1" value="abhor"> abhor
<br>
<input type="radio" name="r1" value="magnificent"> magnificent
<br>
<input type="radio" name="r1" value="counterfeit"> counterfeit
<br>
<input type="radio" name="r1" value="placid"> placid
<br>
<input type="radio" name="r1" value="abrasive">abrasive
<br>
<input type="button" name="Submit" value="Submit" onclick="CheckCheckbox()">
</form>
</body>
</html>
Bookmarks