try
var index=document.form1.rblTime.slectedindex;
alert(index);

解决方案 »

  1.   

    ameng_2002(wader),谢谢你的回答,但rblTime是服务器控件,不能用你的那一句var index=document.form1.rblTime.slectedindex;啵,有办法有没?
    我在html的function中写了这两句
    var rblTime=document.getElementById("rblTime");
    alert(rblTime);
    但显示null.奇怪。
      

  2.   

    try
    document.all("rblTime").selectedIndex
      

  3.   

    不能这么用,一个radiobuttonlist
    <asp:radiobuttonlist id="RadioButtonList1" runat="server">
    <asp:ListItem Value="1">1</asp:ListItem>
    <asp:ListItem Value="2">2</asp:ListItem>
    </asp:radiobuttonlist>
    发送到客户端后是
    <table id="RadioButtonList1" border="0">
    <tr>
    <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="1" /><label for="RadioButtonList1_0">1</label></td>
    </tr><tr>
    <td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="2" /><label for="RadioButtonList1_1">2</label></td>
    </tr>
    </table>
      

  4.   

    try this:<script language=vbscript>
    function GetSelectedRadio()
    for each ob in document.all.tags("input")
    if ob.type="radio" then
    if ob.checked then
    alert(ob.nextSibling.innerText)
    end if
    end if
    next
    end function 
    </script>
      

  5.   

    非常感谢hgknight(江雨.net)的帮忙,但我想问如何可以把你用vbscript写的程序变成javascript呢?因为我需要利用这段程序去控制各个dropdownlist的ITEM数量与值。另外用vbscript或javascript能否对一些控件作出visable的变化呢?作法如何?请指教。
      

  6.   

    Javascript代码是运行在客户端的,而你的RadioButtonList rblTime是运行在服务器上的,要在客户端获得你的RadioButtonList的id,须用rblTime.ClientID.
      

  7.   

    vbscript也可以控制visible嘛
    WebForm1.TextBox1.style.display="none"
      

  8.   

    hgknight(江雨.net):但不能知道用户点了哪个radio.我写了程序如下,radio却轮着被点击。请帮忙看看。
    for (i=0;i<radioSelectNum;i++)
    {
    if (document.all.tags("input").item(i).checked="checked")
    {
    alert('ok   '+ i);
    }
    }
      

  9.   

    try:for var (i=0;i<document.all.Radioname.length;i++){
     if (document.all.Radioname[i].checked)
                alert(i)
    }
      

  10.   

    alf7927(卓不凡),多谢你的帮忙但不成功。
    现在我想从tags标号中得到该控件的ID,如何能做到呢?
    我用了(document.all.tags("input").item(i).type="radio") ,但去提示没有type属性。