I have a problem with performance in IE.
The script above works quite fine when the table has a small number of
elements, but, when the table has 2500 elements, when I click in the
checkbox of the table header (to select all the checkboxes in table),
the script demands at least 3 minutes to execute. I tested the same
script in Mozilla and the response time is much more faster. Does
anyone has an idea?
<script>
function checkFieldAll(f ieldName, checked) {
// Defining the prefix and sufix of the indexed parameter
var prefix = fieldName.subst ring( 0,
fieldName.index Of('[') );
var sufix = fieldName.subst ring( fieldName.index Of(']',
prefix) + 1 );
// Looking for the parameters to be treated matching the
sufix and prefix
var allFields = this.document.f orms[0].elements;
var fields = new Array();
for (i = 0; i < allFields.lengt h; i++) {
var name = allFields[i].name;
if(name != undefined){
if (name.indexOf(p refix) == 0 &&
name.indexOf(su fix) > name.indexOf(pr efix)) {
var elem = allFields[i];
fields.push(ele m);
}
}
}
// check/uncheck the fields
for (i = 0; i < fields.length; i++) {
fields[i].checked = checked;
}
}
function onChangeCheckAl l (checkObject, fieldName) {
checkFieldAll(f ieldName, checkObject.che cked);
}
</script>
and in HTML I have something like:
<table id="lockingsLis t" class="noScroll edList" >
<tr class="noScroll edList">
<th class="noScroll edListHeader" rowspan="2" >
<input type="checkbox" onclick="javasc ript:onChangeCh eckAll(this,
'lockingsList[].isChecked');">
</th>
<th class="noScroll edListHeader" rowspan="2" >
Mnemonic
</th>
</tr>
<tr class="listCell Alternate1">
<td class="listCell ">
<input type="checkbox" name="lockingsL ist[0].isChecked"
value="on" id="lockingsLis t_0_isChecked">
<input type="hidden"
name="lockingsL ist[0].isChecked__gen erated_field__"
value="__FALSE_ CHECKBOX__"
id="lockingsLis t_0_isChecked__ generated_field __">
</td>
<td class="listCell "><span
id="lockingsLis t_0_mnemonic">P 09_H67-1</span>
</td>
</tr>
......
</table>
The script above works quite fine when the table has a small number of
elements, but, when the table has 2500 elements, when I click in the
checkbox of the table header (to select all the checkboxes in table),
the script demands at least 3 minutes to execute. I tested the same
script in Mozilla and the response time is much more faster. Does
anyone has an idea?
<script>
function checkFieldAll(f ieldName, checked) {
// Defining the prefix and sufix of the indexed parameter
var prefix = fieldName.subst ring( 0,
fieldName.index Of('[') );
var sufix = fieldName.subst ring( fieldName.index Of(']',
prefix) + 1 );
// Looking for the parameters to be treated matching the
sufix and prefix
var allFields = this.document.f orms[0].elements;
var fields = new Array();
for (i = 0; i < allFields.lengt h; i++) {
var name = allFields[i].name;
if(name != undefined){
if (name.indexOf(p refix) == 0 &&
name.indexOf(su fix) > name.indexOf(pr efix)) {
var elem = allFields[i];
fields.push(ele m);
}
}
}
// check/uncheck the fields
for (i = 0; i < fields.length; i++) {
fields[i].checked = checked;
}
}
function onChangeCheckAl l (checkObject, fieldName) {
checkFieldAll(f ieldName, checkObject.che cked);
}
</script>
and in HTML I have something like:
<table id="lockingsLis t" class="noScroll edList" >
<tr class="noScroll edList">
<th class="noScroll edListHeader" rowspan="2" >
<input type="checkbox" onclick="javasc ript:onChangeCh eckAll(this,
'lockingsList[].isChecked');">
</th>
<th class="noScroll edListHeader" rowspan="2" >
Mnemonic
</th>
</tr>
<tr class="listCell Alternate1">
<td class="listCell ">
<input type="checkbox" name="lockingsL ist[0].isChecked"
value="on" id="lockingsLis t_0_isChecked">
<input type="hidden"
name="lockingsL ist[0].isChecked__gen erated_field__"
value="__FALSE_ CHECKBOX__"
id="lockingsLis t_0_isChecked__ generated_field __">
</td>
<td class="listCell "><span
id="lockingsLis t_0_mnemonic">P 09_H67-1</span>
</td>
</tr>
......
</table>
Comment