G
Gui Lloyd
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(fieldName, checked) {
// Defining the prefix and sufix of the indexed parameter
var prefix = fieldName.substring( 0,
fieldName.indexOf('[') );
var sufix = fieldName.substring( fieldName.indexOf(']',
prefix) + 1 );
// Looking for the parameters to be treated matching the
sufix and prefix
var allFields = this.document.forms[0].elements;
var fields = new Array();
for (i = 0; i < allFields.length; i++) {
var name = allFields.name;
if(name != undefined){
if (name.indexOf(prefix) == 0 &&
name.indexOf(sufix) > name.indexOf(prefix)) {
var elem = allFields;
fields.push(elem);
}
}
}
// check/uncheck the fields
for (i = 0; i < fields.length; i++) {
fields.checked = checked;
}
}
function onChangeCheckAll (checkObject, fieldName) {
checkFieldAll(fieldName, checkObject.checked);
}
</script>
and in HTML I have something like:
<table id="lockingsList" class="noScrolledList" >
<tr class="noScrolledList">
<th class="noScrolledListHeader" rowspan="2" >
<input type="checkbox" onclick="javascriptnChangeCheckAll(this,
'lockingsList[].isChecked');">
</th>
<th class="noScrolledListHeader" rowspan="2" >
Mnemonic
</th>
</tr>
<tr class="listCellAlternate1">
<td class="listCell">
<input type="checkbox" name="lockingsList[0].isChecked"
value="on" id="lockingsList_0_isChecked">
<input type="hidden"
name="lockingsList[0].isChecked__generated_field__"
value="__FALSE_CHECKBOX__"
id="lockingsList_0_isChecked__generated_field__">
</td>
<td class="listCell"><span
id="lockingsList_0_mnemonic">P09_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(fieldName, checked) {
// Defining the prefix and sufix of the indexed parameter
var prefix = fieldName.substring( 0,
fieldName.indexOf('[') );
var sufix = fieldName.substring( fieldName.indexOf(']',
prefix) + 1 );
// Looking for the parameters to be treated matching the
sufix and prefix
var allFields = this.document.forms[0].elements;
var fields = new Array();
for (i = 0; i < allFields.length; i++) {
var name = allFields.name;
if(name != undefined){
if (name.indexOf(prefix) == 0 &&
name.indexOf(sufix) > name.indexOf(prefix)) {
var elem = allFields;
fields.push(elem);
}
}
}
// check/uncheck the fields
for (i = 0; i < fields.length; i++) {
fields.checked = checked;
}
}
function onChangeCheckAll (checkObject, fieldName) {
checkFieldAll(fieldName, checkObject.checked);
}
</script>
and in HTML I have something like:
<table id="lockingsList" class="noScrolledList" >
<tr class="noScrolledList">
<th class="noScrolledListHeader" rowspan="2" >
<input type="checkbox" onclick="javascriptnChangeCheckAll(this,
'lockingsList[].isChecked');">
</th>
<th class="noScrolledListHeader" rowspan="2" >
Mnemonic
</th>
</tr>
<tr class="listCellAlternate1">
<td class="listCell">
<input type="checkbox" name="lockingsList[0].isChecked"
value="on" id="lockingsList_0_isChecked">
<input type="hidden"
name="lockingsList[0].isChecked__generated_field__"
value="__FALSE_CHECKBOX__"
id="lockingsList_0_isChecked__generated_field__">
</td>
<td class="listCell"><span
id="lockingsList_0_mnemonic">P09_H67-1</span>
</td>
</tr>
......
</table>