[thelist] JavaScript Drop Box Clear...

Mike King mike.king at redroom.co.uk
Wed Feb 21 13:14:29 CST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

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?

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

function clear(DropNum){
if (DropNum == 1||DropNum == 0) {
   with (window.document.qsearch.RegionID) {
         for (var i=0;i<options.length;i++){
         options[i]=null;
   }
         options[0]=new Option('--------------------------', '0');
  }
}
if (DropNum == 2) {
   with (window.document.qsearch.RegionID2) {
         for (var i=0;i<options.length;i++){
         options[i]=null;
   }
         options[0]=new Option('--------------------------', '0');
  }
}
if (DropNum == 3) {
   with (window.document.qsearch.RegionID3) {
         for (var i=0;i<options.length;i++){
         options[i]=null;
   }
         options[0]=new Option('--------------------------', '0');
  }
}
}

Cheers
mk

- --
http://www.redroom.co.uk
t. 07971 292 999
e. mike.king at redroom.co.uk
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBOpQF+/oJZSzUdy33EQK/VgCg13jNluH39rUjbC4qxLtwygTv3GsAoMm0
2900Xleeg/1zusqLw+m+Ckiz
=wSrT
-----END PGP SIGNATURE-----





More information about the thelist mailing list