Count number of selected items in dropdown menu

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.
LVL 2
CUTTHEMUSICAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
fritz_the_blankConnect With a Mentor Commented:
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
 
CUTTHEMUSICAuthor Commented:
That was easy
0
All Courses

From novice to tech pro — start learning today.