| Author |
Sort text in select
|
Sophie Cameron
Greenhorn
Joined: Jun 05, 2005
Posts: 24
|
|
We wrote code to sort select text but it is not efficient if there are more than 1,000 entries. Since select.options is read-only, we can't use Array.sort() to do it. If you need to sort select entries, how would you do it? Thanks,
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
What are you trying to do with this, there might be a better way of doing it. Where is the information coming from? Eric
|
 |
Sophie Cameron
Greenhorn
Joined: Jun 05, 2005
Posts: 24
|
|
Hi Eric, What I want to do is when a new entry needs to be added to a select, I want it to be added alphabetically. The original select is already rendered alphabetically. Here is my code to do it: Many Option objects are created in the second loop, which is the bottleneck. The performance could be [bold]greatly[/bold] improved if the could be replaced with but actually not. Thanks,
|
 |
Sophie Cameron
Greenhorn
Joined: Jun 05, 2005
Posts: 24
|
|
The leftSelect in the second for loop should be mySelect. Sorry about that.
|
 |
 |
|
|
subject: Sort text in select
|
|
|