1. Open the file that contains your listbox code.
2. Locate the variable name of your listbox as well as the variable name for the elements inside the listbox. For this example, the variable name of the listbox element is "myListBox" and the variable name of the elements in the listbox is "lbcontents".
3. Type "var countSelected = document.getElementById("lbcontents").options.length;" in your code to create a new variable ("countSelected") that is set to the number of elements in the listbox.
- website layout image by 6922Designer from Fotolia.com