Not completely sure what it is you're trying to do.
However if you're trying to get/manipulate the value of a radio button depending on wether it is checked or not, that I can do.
Here's an example:
[HTML]<html>
<head>
<script type="text/javascript">
function check() {
/* theCorrect is going to store the
correct answer's value */
/* theValue is going to store the
value of the user's input */
/* response is going to be the
computer's output */
var theCorrect;
var theValue;
var response;
//The
for loop will check each radio button
/* i <= 3; may seem a little odd because there's
4 radio buttons, but the first rabio button is
treated as the 0th button,
the second radio as the 1rst,
and so on */
/* if one of the radio buttons is checked it gives
that value to the variable theValue */
for (i = 0; i <= 3; i++) {
if (document.myForm.answer[i].checked == true) {
theValue=document.myForm.answer[i].value;
}
}
correct="4";
if (theValue == correct) {
response ="Congrats! You got it!";
document.myForm.txtResponse.value=response;
} else {
response ="Sorry," + " ";
response +=theValue;
response +=" " + "is not correct.";
document.myForm.txtResponse.value=response;
}
}
</script>
</head>
<body>
<p>
What's 2+2?
</p>
<form name="myForm">
<table border="1">
<tr>
<td>
<!-- by giving the radio buttons the same name,
only one can be checked at a time -->
<input type="radio" name="answer" value="1" />1
<input type="radio" name="answer" value="2" />2
<input type="radio" name="answer" value="3" />3
<input type="radio" name="answer" value="4" />4
</td>
</tr>
<tr>
<td>
<input type="button" onClick="check()" value="Submit" />
</td>
</tr>
<tr>
<td>
<!-- This is where the computer's output will be,
you can do the same with with a textarea
as well -->
<input type="text" name="txtResponse" />
</td>
</tr>
</table>
</form>
</body>
</html>[/HTML]
Ironicly I had the same error last night while working on a quiz program that's purely JavaScript and HTML. I forget now how I fixed it.
Hope it helps, Thanks, Death
PS - I remember what it was I did now. I had 6 radio buttons per question, and each set of buttons had their own name. The problem was in this line:
- for (i = 0; i <= 6; i++) {
-
-
}
The problem as you might have guessed is in the "i <= 6;" section. This is telling the browser that there's 7 radio buttons, but I only had 6. I changed the line to "i <= 5;" and it worked like a charm.