Jump to content

Lag in while loop


Thierry

Recommended Posts

I have a while loop (4096 is the minimum amount) which goes through a long list of cells.

Although saving 4096 cells is do-able, when it gets more, the browser thinks the script has gotten stuck and it takes forever to finish it.

 

In the loop, all it does is get the table cell ('with frames["framename"].document.getElementById(tile_counter)') and then get a style from it and checks a few things with the result.

When a result matches a certain thing, it will update a field with the value.

I'll end up with a hidden field having a lot of values separated by commas. (green,black,yellow,red,purple etc)

 

When I removed the getElementById part the script was finished instantly, so I'm geussing using 4096 getElementById's is what is causing the lag.

 

Is there another way of getting the table cell without causing much lag? I only need the style.backgroundColor attribute.

Link to comment
Share on other sites

i'm not sure i get your problem. are you saying you're changing the background color of every <td></td> cell in a table and there are 4,096 cells?

 

if so, might I ask, why not just set the background color for the entire table?  that would be 1 css action instead of 4,096. --never mind:

 

maybe you could post a snippet of code, i'm not sure what you're trying to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.