Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome hangs when using javascript to check many checkboxes, while firefox does it instantly
    text
    copied!<p>I'm using an asp:Repeater server side control that contains a table as it's repeatable item. One of the td tags in the table contains a checkbox. In the header of the repeater I have a checkbox with id="selectAllCheck".</p> <p>I have the following javascript code</p> <pre><code> var checkBox = document.getElementById('selectAllCheck'); function changeAll() { if (checkBox.checked == 1) { $('input:checkbox').attr('checked', "checked"); } else { $('input:checkbox').attr('checked', ""); } } checkBox.onchange = changeAll; </code></pre> <p>This works just fine in firefox, instantly all the checkboxes are either checked or unchecked when necessary. However, in chrome it takes about 10 seconds. I do have about 250 checkboxes on the page by the way, but even putting that number down to only 15, I can see that it is still not instant with chrome, but much faster.</p> <p>If anyone has encountered this problem before, seen any articles related to this problem, or knows how to solve this problem I would be very thankful.</p> <p>EDIT: Posted the page</p> <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" Runat="Server"&gt; &lt;form id="webForm" runat="server"&gt; &lt;asp:Label ID="sourceLabel" runat="server" AssociatedControlID="sourceList" Text="Source"&gt;&lt;/asp:Label&gt; &lt;asp:DropDownList ID="sourceList" runat="server" /&gt;&amp;nbsp; &lt;asp:Button ID="showButton" runat="server" Text="View" /&gt; &lt;asp:Repeater ID="Repeater_DIBS" runat="server"&gt; &lt;HeaderTemplate&gt; &lt;table&gt; &lt;tr&gt;&lt;th&gt;&lt;input type="checkbox" id="selectAllCheck" /&gt; (un)check All&lt;/th&gt; &lt;th&gt;SourceID&lt;/th&gt;&lt;th&gt;FieldID&lt;/th&gt;&lt;th&gt;Source Indicator&lt;/th&gt;&lt;th&gt;Date Data Updated&lt;/th&gt; &lt;th&gt;Message&lt;/th&gt;&lt;/tr&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td style='width:1%;white-space:nowrap;'&gt;&lt;input type='checkbox' class='checkBoxes' /&gt;&lt;/td&gt; &lt;td style='width:1%;white-space:nowrap;'&gt;&lt;%# Eval("SourceID") %&gt;&lt;/td&gt; &lt;td style='width:1%;white-space:nowrap;'&gt;&lt;%# Eval("FieldID") %&gt;&lt;/td&gt; &lt;td class='indicator' style='width:1%;white-space:nowrap;'&gt;&lt;%# Eval("SourceIndicator") %&gt;&lt;/td&gt; &lt;td style='width:1%;white-space:nowrap;'&gt;&lt;%# Eval("DateDataUpdated") %&gt;&lt;/td&gt; &lt;td style='width:1%;white-space:nowrap;' class='status'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; &lt;/table&gt; &lt;/FooterTemplate&gt; &lt;/asp:Repeater&gt; &lt;/form&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content3" ContentPlaceHolderID="ContentJS" Runat="Server"&gt; &lt;script type="text/javascript"&gt; $("#selectAllCheck").change(function () { if (this.checked) { $("input:checkbox.checkBoxes").attr("checked", "checked"); } else { $("input:checkbox.checkBoxes").removeAttr("checked"); } }); &lt;/script&gt; &lt;/asp:Content&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload