ARACK04
asked on
Clearing options collection of Javascript select
Is there a fast way to clear all items from a javascript select? I've got about 100,000 items in there, returned from some query, and I want to simply dump its contents before the page posts back. Saying:
$get(name).options.length = 0
took too long, and
$get(name).options = new Array(); threw an exception. Is there some other way?
$get(name).options.length = 0
took too long, and
$get(name).options = new Array(); threw an exception. Is there some other way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you tried:
$get("selectId").options=n ull;
OR
$get("selectId").options=n ew Array();
$get("selectId").options=n
OR
$get("selectId").options=n
ASKER
yeah, tried them both, both slow. Thanks for the help.
ASKER
Despite being part of the "AJAX" library, it's pure javascript, and doesn't involve the XMLHttpRequestObject, so it's not causing my slowdown.
I tried setting length = 0 - for a dropdown of about 7,000 items it took about a half a second, and the time just skyrockets as it increases to 100,000.
If this is the fastest I can get, then I guess I have to look elsewhere. Thanks.