我有一个radiobuttonlist 我现在想用javascript 判断radiobuttonlist选项是否选中,这个应该怎么做

解决方案 »

  1.   

    点击后传入this对象
    function ClickRadio(ob)
    {
       if(ob.value == "选项值")
       {
          ob.checked = true;
       }
    }
      

  2.   

    遍历控件,type=radio,if(checked)就可以了
      

  3.   

    document.getElementById("ralist").checked
      

  4.   

    不好意思看错了,看成单个radio了
      

  5.   


    <asp:RadioButtonList ID="rbl" runat="server" RepeatDirection="Horizontal">
         <asp:ListItem Value="0">是</asp:ListItem>
         <asp:ListItem Value="1">否</asp:ListItem>
    </asp:RadioButtonList>
    <input id="Button4" type="button" onclick="rblSel()" value="button" /><script type="text/javascript">
        function rblSel()
        {
            var obj =document.all.rbl;
            for(i=1;i<obj.length;i++)
            {
                alert(document.all.rbl[i].checked);
            }
        }
        </script>
      

  6.   

    在代码里写不行么?!
    if(this.RadioButtonList名.Items[0].Selected == true)
    {
    }
      

  7.   

    RadioBox有checked属性,检查它的状态值为true或false.
      

  8.   

    个人感觉连选择RadioButtonList都需要确定的话会比较不爽!
    回传不应该在RadioButtonList身上。
      

  9.   


    function IsRadChk(RadName)//RadName为RadioButtonList的ID
    {
     var ischk=false;
     var RadobjArr= document.getElementById(RadName);
     for(var i=0;i<radobjArr.length;i++)
     {
       var Radobj=radobjArr[i];
       if(Radobj.checked)
       {
         ischk=true;
         break;
       }
     }
     alert(ischk);
    }
      

  10.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <style type="text/css">
            .style2
            {
                width: 300px;
                border-style: solid;
                border-width: 1px;
                border-color:Green;
            }
            </style>
         <script language="javascript" type="text/javascript">
            function checkSelect()
            {
                var obj = document.getElementById("rbtnTest").rows.length;
                //alert(obj);
                for(i=0;i<obj;i++)
                {
                    var item = "rbtnTest_" + i;
                    if(document.getElementById(item).checked == true)
                    {
                        alert("您选中了:"document.getElementById(item).value);
                    }
                }
            }
         </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
    <asp:RadioButtonList ID="rbtnTest" runat="server">
         <asp:ListItem>0</asp:ListItem>
         <asp:ListItem>1</asp:ListItem>
         <asp:ListItem>2</asp:ListItem>
         <asp:ListItem>3</asp:ListItem>
      </asp:RadioButtonList>
      <input type="button" id="Test" name="Test" value="Test" onclick="checkSelect()" />
     </div>
     </form>
    </body>
    </html>
    楼主可以使用这一段代码,本人经过测试可用。