kk1076
kk1076

Reputation: 1748

Javascript not implemented error in Internet Explorer

i used a javascript code for radiobtn check inside gridview. the code works fine in firefox browser. but in internet explorer (IE) the code is not working and the error says Javascript not implemented. my javascript code is

<script type="text/javascript">
    function CheckOtherIsCheckedByGVID(rb) {

        var isChecked = rb.checked;
        var row = rb.parentNode.parentNode;
        if (isChecked) {
            row.style.backgroundColor = '#C4DFFB';
            row.style.color = 'black';
        }
        var currentRdbID = rb.id;
        parent = document.getElementById("<%= grdEventDetails.ClientID %>");
        var items = parent.getElementsByTagName('input');

        for (i = 0; i < items.length; i++) {
            if (items[i].id != currentRdbID && items[i].type == "radio") {
                if (items[i].checked) {
                    items[i].checked = false;
                    items[i].parentNode.parentNode.style.backgroundColor = 'white';
                    items[i].parentNode.parentNode.style.color = '#696969';
                }
            }
        }
    }
</script>

my implementation in gridview code is

   <asp:TemplateField>
     <ItemStyle HorizontalAlign="Left" />
    <ItemTemplate>
   <asp:RadioButton ID="grdRdo" runat="server"
 onclick="javascript:CheckOtherIsCheckedByGVID(this);" />
  </ItemTemplate>
   </asp:TemplateField>

Upvotes: 4

Views: 3004

Answers (3)

Jon Hulka
Jon Hulka

Reputation: 1309

change

parent = document.getElementById("<%= grdEventDetails.ClientID %>");

to:

var parent = document.getElementById("<%= grdEventDetails.ClientID %>");

IE seems to like the 'var' in there when you are declaring variables.

Upvotes: 0

sisve
sisve

Reputation: 19781

Try renaming the parent variable. It sounds like something that would conflict with the pre-existing environment.

Upvotes: 2

Sel&#231;uk
Sel&#231;uk

Reputation: 176

Try adding "onclick" event on your Page_Load function:

grdRdo.Attributes.Add("onclick", "CheckOtherIsCheckedByGVID(this)");

Upvotes: 0

Related Questions