Quantum Thoughts

Quickie. Empty select.

Posted by: doxaras on: November 5, 2009

Some ie6 bug prevent from properly clearing the options of a select html element. This is an issue the actual length that myselect.options.length statement returns. The smart way to do this is with a while loop.

            function removeSelects(elementId){
                var myselect = document.getElementById(elementId);
                for(var i=0; i<myselect.options.length; i++){
                    myselect.options[i] = null;
                }
                while (myselect.options.length > 0) {
                    myselect.options[0] = null;
                }
            }

Leave a Reply

Flickr Photos

1236774486863

HPIM2363

HPIM2362

HPIM2359

More Photos

My Bookmarks

 

November 2009
M T W T F S S
« Oct   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Blog Stats

  • 26,443 hits