JavaScript代码仅适用于IE

时间:2012-07-18 07:05:32

标签: javascript asp.net datagrid

在我的页面上我有一些JS代码。它仅适用于IE。不适用于Firefox和谷歌浏览器。

当Datagrid的checkox onclick函数时,JS函数会触发..

<asp:TemplateColumn Visible="true">
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="chkSelect" Runat="server" onclick="kontrol(this);"></asp:CheckBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>

这是JS代码..

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
    var secilenler = "";
    var birim = "";
    function kontrol(obj) {
        var sira = parseInt(obj.id.substring(obj.id.length - 1, obj.id.length)) + 1;
        var grid = document.getElementById("<%= grdIslemler.ClientID %>");
        if (secilenler == "") {
            secilenler += obj.id + "|";
            birim = grid.rows(sira).cells(1).innerHTML;
        }
        else {
            if (birim == grid.rows(sira).cells(1).innerHTML) {
                secilenler += obj.id + "|";
            }
            else {
                secilenler = secilenler.substring(0, secilenler.length - 1);
                var arr = new Array();
                arr = secilenler.split("|");
                for (var i = 0; i < arr.length; i++) {
                    var chk = document.getElementById(arr[i]);
                    chk.checked = false;
                    secilenler = obj.id + "|";
                    birim = grid.rows(sira).cells(1).innerHTML;
                }
            }
        }
    }
</script>

0 个答案:

没有答案