我要实现连两个RadioButtonList 中,只能选择一个RadioButton,所以我想到来更改RadioButton的name值,有办法吗?我试了好多都不行?或者还有别的方法实现吗?
-------------
或者在同一个RadioButtonList 中,有办法改变个别的RadioButton的字颜色吗?
在线等,解决马上揭贴,分不够,再加

解决方案 »

  1.   

    <asp:RadioButtonList ID="rblUser" runat="server" AutoPostBack="True" OnSelectedIndexChanged="rblUser_SelectedIndexChanged"></asp:RadioButtonList>什么name值,不懂
      

  2.   

    只能选择一个,那为啥要用两个RadioButtonList
      

  3.   

    <asp:RadioButtonList ID="rblUser1" runat="server" AutoPostBack="True"></asp:RadioButtonList>
    <asp:RadioButtonList ID="rblUser2" runat="server" AutoPostBack="True"></asp:RadioButtonList>//绑定这两个RadioButtonList后:
    foreach (RadioButton button in this.rblUser1.Items)
            {
                button.GroupName= "user";
            }
            foreach (RadioButton button in this.rblUser2.Items)
            {
                button.GroupName = "user";
            }//这样就只能从这两组里面选择一项了
      

  4.   

    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
        <script type="text/javascript">
        function changeradiobuttonlistname(){
            var rs=document.getElementsByTagName("INPUT");
            
            for(var i=0;i<rs.length;i++){
                if(rs[i].type=="radio"){
                    var sour=rs[i].parentNode.innerHTML;
                    var desc=sour.replace(/name=[^\>]+/gi,"name='newname'");
                    rs[i].parentNode.innerHTML=desc;
                   alert(desc);
                }
            }
        }
        </script>
    </head>
    <body onload="javascript:changeradiobuttonlistname();">
        <form id="form1" runat="server">
        <div>
        <asp:RadioButtonList runat="server" ID="rbl1">
        <asp:ListItem Text="11"></asp:ListItem>
        <asp:ListItem Text="12"></asp:ListItem>
        </asp:RadioButtonList>
        <asp:RadioButtonList runat="server" ID="rbl2">
        <asp:ListItem Text="21"></asp:ListItem>
        <asp:ListItem Text="22"></asp:ListItem>
        </asp:RadioButtonList>
        </div>
        </form>
    </body>
    </html>
      

  5.   

    还是不能成功啊
    上面的大哥的弄法
    我感觉是可行的,不知道是不是我的改法不对,望能帮我看看
    ----------------
    var rs = document.getElementById("RadioButtonList1").getElementsByTagName("INPUT");
    for(i = 0;i<rs.length;i++)
    {
    if(rs[i].type=="radio"){
              var sour=rs[i].parentNode.innerHTML;
              var desc=sour.replace("name=\"RadioButtonList1\"","name='RadioButtonList2'");
                    rs[i].parentNode.innerHTML=desc;
                    window.alert(desc)
                }
             }
      

  6.   

    zhjg136(天星) ( ) 
    ---------
    这个大哥的不可行,因为Items的类型根本就不是RadioButton
      

  7.   

    可以了
    谢谢Top  
     blackant2(乔峰) ( ) 
    大哥
    再次感谢
    是我弄错了的
    呵呵