Solved

Count number of selected items in dropdown menu

Posted on 2001-07-10
2
1,573 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now