<asp:RadioButtonList ID="rblCustomerType" runat="server" Height="1px" RepeatDirection="Horizontal"
RepeatLayout="Flow" Width="218px">
<asp:ListItem Value="0">AAA</asp:ListItem>
<asp:ListItem Value="2">BBB</asp:ListItem>
<asp:ListItem Value="5">CCC</asp:ListItem>
</asp:RadioButtonList>-------
function CheckIsCanNewRow2()
{
   document.getElementById('rblCustomerType').value =2;
}
---
想用JS实现对,RadioButtonList ,的选中操作,请问怎么实现?

解决方案 »

  1.   

    我用   //document.getElementById('rblCustomerType_2').checked =true;这种方法实现了,单这种必须"_2(xxx)"的方法,不是很好...请问有更好的方法了吗?
      

  2.   


    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      
      <script>
     function aa()
     {
     var inputs = document.getElementById("rblCustomerType").getElementsByTagName("INPUT")
     for(i = 0;i<inputs.length;i++)
     {
      if(inputs[i].name=="rblCustomerType") alert(inputs[i].value)
     }
     }
      </script>
    </head>
    <body>
      <form id="form1" runat="server">
    <asp:RadioButtonList ID="rblCustomerType" runat="server" Height="1px" RepeatDirection="Horizontal"
    RepeatLayout="Flow" Width="218px">
    <asp:ListItem Value="0">AAA</asp:ListItem>
    <asp:ListItem Value="2">BBB</asp:ListItem>
    <asp:ListItem Value="5">CCC</asp:ListItem>
    </asp:RadioButtonList>
    <input type=button onclick="aa()" value="控制">
      </form>
    </body>
    </html>