Ok so the RadioButtonList produces the following HTML
<table id="rblList" border="0">
<tr>
<td><input id="rblList_0" type="radio" name="rblList" value="s1" /><label for="rblList_0">s1</label></td>
</tr>
<tr>
<td><input id="rblList_1" type="radio" name="rblList" value="s2" /><label for="rblList_1">s2</label></td>
</tr>
<tr>
<td><input id="rblList_2" type="radio" name="rblList" value="s3" /><label for="rblList_2">s3</label></td>
</tr>
<tr>
<td><input id="rblList_3" type="radio" name="rblList" value="s4" /><label for="rblList_3">s4</label></td>
</tr>
</table>
According to MSDN I'm getting 5 elements because I'm getting the radio buttons AND the table that ASP.Net it putting them in:
http://msdn.microsoft.com/en-us/library/ms536438%28VS.85%29.aspx
When you use the getElementsByName method, all elements in the document
that have the specified NAME attribute
or ID attribute value are returned.
So, putting this bit of javaScript on the page:
function showEle() {
var elements = document.getElementsByName("rblList");
alert("elements length=" + elements.length);
for (var i = 0; i < elements.length; i++) {
try {
alert("elements[" + i + "]" + ", id=" + elements[i].id + ", name=" + elements[i].name + ", value = " + elements[i].value);
}
catch (ex) {
alert("error reading elements[" + i + "].value");
}
}
}
I was able to see this...
elements[0], id=rblList, name=undefined, value = undefined
elements[1], id=rblList_0, name=rblList, value = s1
elements[2], id=rblList_1, name=rblList, value = s2
elements[3], id=rblList_2, name=rblList, value = s3
elements[4], id=rblList_3, name=rblList, value = s4
element[0]
is the table, the others are the radio buttons