[thelist] Script to select all options in select dropdown

Jeremy Ashcraft ashcraft at 13monkeys.com
Thu, 02 Dec 1999 10:06:19 -0600


Add the MULTIPLE attribute to your <SELECT> tag.  By defulat it only allows you
to select one option.

<SELECT NAME="subject" SIZE="4" MULTIPLE>

--
Jeremy Ashcraft
web developer/geek
ashcraft@13monkeys.com
http://www.13monkeys.com


"Miller, Bart" wrote:

> I am trying to write a script to select all options in a dropdown menu.
> This would be the equivalent of holding down the control key as you click on
> each item.  But for some reason the code below only selects the last one in
> my loop and not all of them as I would expect. Any ideas?  Here's the code:
>
> <script>
> function selectall() {
> tot = document.testform.subject.options.length ;
> for (i=0;i<tot;i++) {
> document.testform.subject.options[i].selected = true;
> }
> }
> </script>
>
> <form name=testform>
> <SELECT NAME = "subject" size=4>
> <OPTION>First
> <OPTION>Second
> <OPTION>Third
> <OPTION>Fourth
> </SELECT>
> </form>
> <a href="#" onclick="selectall()">Select All</a>
>
> _______________________________________________________
> unsubscribe+options: http://lists.evolt.org/mailman/listinfo/thelist
> tip harvester: http://lists.evolt.org/harvest/
> email archive: http://lists.evolt.org/archive/
> http://evolt.org/  Workers of the Web, evolt !