[thelist] JavaScript Drop Box Clear...

Warden, Matt mwarden at odyssey-design.com
Wed Feb 21 14:56:57 CST 2001


> I've got a javascript function that clears a drop down menu, but it seems
> that if there's too many items it doesn't clear them all. Is there anything
> wrong with the function?

Yes (but not syntactically).

> Also, is there any way I can compress this down and make it a generic
function?

Yes. Here:

function clear(objSelect){

     for (var i = (objSelect.options.length-1); i >= 0; i--){
         options[i]=null;
     }
     options[0]=new Option('--------------------------', '0');
}



HTH,


--
mattwarden
mattwarden.com





More information about the thelist mailing list