Solved

Count number of selected items in dropdown menu

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

815 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

11 Experts available now in Live!

Get 1:1 Help Now