Solved

Count number of selected items in dropdown menu

Posted on 2001-07-10
2
1,576 Views
Last Modified: 2008-02-01
I have a dropdown menu that allows multiple selections. I want to count the number of items selected in the menu. How do I do this.
0
Comment
Question by:CUTTHEMUSIC
2 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 25 total points
ID: 6270331
Let's say that you have a form named "form" and your dropdown is called "menuname," then:

Function CountMe()
{
   var i=0;
   var numSelected = 0;

   for (i=0; i<form.menuname.length; i++)
   {
        if(form.menuname[i].selected)
        {
             numSelected = numSelected + 1;
        }
   }
return numSelected
}
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 6270360
That was easy
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Select case on click 3 19
Html form and modal / img src -problem 3 30
html input 8 42
How to control cache of some js files ? 7 39
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question