代码如下:
//得到radiobuttonlist
var vRblIsDescription=document.getElementById("rblIsDescription");
//得到所有radio
var rbs= vRblIsDescription.getElementsByTagName("INPUT");
for(var i = 0;i<rbs.length;i++)
{
if(rbs[i].checked)
{
var text =vRblIsDescription.cells[i].innerText;
var value=rbs[i].value;
alert("选中项的text值为"+text+",value值为"+value);
}
}
var vRblIsDescription=document.getElementById("rblIsDescription");
//得到所有radio
var rbs= vRblIsDescription.getElementsByTagName("INPUT");
for(var i = 0;i<rbs.length;i++)
{
if(rbs[i].checked)
{
var text =vRblIsDescription.cells[i].innerText;
var value=rbs[i].value;
alert("选中项的text值为"+text+",value值为"+value);
}
}
RadioButtonList在客户端被看成成了table,通过getElementsByTagName("INPUT")方法获取它的所有子radio,然后循环每个radio,再通过cells获取radio的text值。