0

我有一个单选按钮列表

 <asp:RadioButtonList CssClass="radioLable" ID="rbListPointsCat" runat="server"   RepeatDirection="Horizontal"
                    AutoPostBack="true" OnSelectedIndexChanged="rbListPointsCat_SelectedIndexChanged">
                    <asp:ListItem runat="server" Value="Yes" />
                    <asp:ListItem runat="server" Value="No" />
                </asp:RadioButtonList>

我正在使用以下 JS 函数

          function CheckValue(sender, args) {

        var rblist = document.getElementById('<% =rbListPointsCat.ClientID%>');
        for (var x = 0; x < rblist.cells.length; x++) {
            if (rblist.cells[x].checked) {
                var Choice = (rblist.cells[x].innerText);
                alert(Choice);
            }
        }


        if (Choice=="No") {
            if (txtRemarks.value == "") {
                args.IsValid = false;
            }
            else {
                args.IsValid = true;
            }
        }
        else {
            args.IsValid = true;
        }
    }

但无法获得检查的 valur ..它即将是未定义的。请让我知道我哪里出错了?

4

1 回答 1

0

直呼其名,

      function CheckValue(sender, args) {

    var rblist = document.getElementByName('<% =rbListPointsCat.ClientID%>');
    for (var x = 0; x < rblist.cells.length; x++) {
        if (rblist.cells[x].checked) {
            var Choice = (rblist.cells[x].innerText);
            alert(Choice);
        }
    }


    if (Choice=="No") {
        if (txtRemarks.value == "") {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }
    }
    else {
        args.IsValid = true;
    }
}
于 2013-02-13T12:06:31.800 回答