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?
ARACK04Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
if you give the select list an id:
<select id="someList">...</select>
then you can simply say:
document.getElelementById("someList").options.length=0;

That will be the fastest. What does $get() do for you? I suspect it is doing an AJAX call. If anything, the AJAX call is the one that is causing the delay.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ARACK04Author Commented:
$get is part of the Microsoft AJAX JavaScript library - it's a replacement for document.getElementById

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.
0
hieloCommented:
Have you tried:
$get("selectId").options=null;
OR
$get("selectId").options=new Array();
0
ARACK04Author Commented:
yeah, tried them both, both slow.  Thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.