js得到RadioButtonList选中的值【asp.net单选控件】

页面代码:

<asp:RadioButtonListonclick="hao()" runat="server"

RepeatDirection="Horizontal">

</asp:RadioButtonList>

js部分:

<script type="text/javascript">

function hao()

{

var aa=document.getElementsByName("RadioButtonList1");

var cc="";

for(var i=1;i <aa.length;i++)

{

if(aa[i].checked)

{

cc=aa[i].value;

}

}

if(cc=="21")

{

document.getElementById("hwmc").style.display="";

document.getElementById("hwsl").style.display="";

}

if(cc=="22")

{

document.getElementById("hwmc").style.display="none";

document.getElementById("hwsl").style.display="none";

}

}

</script>