plq
asked on
Slow javascript loop..
Any ideas how to speed this up ?
I've tried the easier option of running thru maintable.all but thats even worse. Its a long table in a scrollable div
1. Is there a way of doing a bulk change to many elements at once
2. Is there some kind of doevents function in js that will allow the user to continue working as it runs ?
3. Any other thoughts on speeding it up ?
function doedit()
{
var ctl;
var ctltypes = new Array("SELECT", "INPUT", "TEXTAREA");
// perf improv over scanning all tags
for (var c = 0; c < ctltypes.length; c++)
{
for (var k = 0; k < maintable.all.tags(ctltype s[c]).leng th; k++)
{
ctl = maintable.all.tags(ctltype s[c])[k];
if (ctl.disabled)
{
ctl.disabled = false;
}
}
}
}
thanks
I've tried the easier option of running thru maintable.all but thats even worse. Its a long table in a scrollable div
1. Is there a way of doing a bulk change to many elements at once
2. Is there some kind of doevents function in js that will allow the user to continue working as it runs ?
3. Any other thoughts on speeding it up ?
function doedit()
{
var ctl;
var ctltypes = new Array("SELECT", "INPUT", "TEXTAREA");
// perf improv over scanning all tags
for (var c = 0; c < ctltypes.length; c++)
{
for (var k = 0; k < maintable.all.tags(ctltype
{
ctl = maintable.all.tags(ctltype
if (ctl.disabled)
{
ctl.disabled = false;
}
}
}
}
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try document.getElementsByTagN ame
ASKER
Hmmm dont know whats going on here
function doedit()
{
var ctl;
var ctltypes = new Array("SELECT", "INPUT", "TEXTAREA");
// perf improv over scanning all tags
for (var c = 0; c < ctltypes.length; c++)
{
var ctls = maintable.parentElement.ge tElementsB yTagName(c tltypes[c] );
for (var k = 0; k < ctls.length; k++)
{
ctl = ctls[k];
if (ctl.disabled) ctl.disabled = false;
}
}
}
keeps saying getElementsByTagName is undefined?
Yet the msdn sample runs ok on my machine
Browser is ie6
function doedit()
{
var ctl;
var ctltypes = new Array("SELECT", "INPUT", "TEXTAREA");
// perf improv over scanning all tags
for (var c = 0; c < ctltypes.length; c++)
{
var ctls = maintable.parentElement.ge
for (var k = 0; k < ctls.length; k++)
{
ctl = ctls[k];
if (ctl.disabled) ctl.disabled = false;
}
}
}
keeps saying getElementsByTagName is undefined?
Yet the msdn sample runs ok on my machine
Browser is ie6
ASKER
hold on...
ASKER
OK it works
But not substantially faster. I think the drag must be on setting .disabled.
But not substantially faster. I think the drag must be on setting .disabled.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Quite weird actually
Theres about 7000 controls with the tag types we want. This is an xml data bound table, so only one control at design time per field
It takes about one minute using the latest proposal above. But after the js function has exited (its called off a button), the browser locks up for another minute, and no js is running (I can prove that from breaking the net2003 debugger). Then the page finally comes back with the controls enabled.
Its obviously a design problem in having that many controls, but you'd hope there was a way of enabling them a bit faster.
I'm going to try enabling the whole table or its wrapper div to see if that works.
Theres about 7000 controls with the tag types we want. This is an xml data bound table, so only one control at design time per field
It takes about one minute using the latest proposal above. But after the js function has exited (its called off a button), the browser locks up for another minute, and no js is running (I can prove that from breaking the net2003 debugger). Then the page finally comes back with the controls enabled.
Its obviously a design problem in having that many controls, but you'd hope there was a way of enabling them a bit faster.
I'm going to try enabling the whole table or its wrapper div to see if that works.
ASKER
Thats worked. table elements seem to support the disabled tag
but select elements as usual cause problems and are enabled, I can work around that.
I'll just split points as I appreciate everyones attempt to help on this..
thanks
but select elements as usual cause problems and are enabled, I can work around that.
I'll just split points as I appreciate everyones attempt to help on this..
thanks
You are welcome.