There is no list box. I think you are referring to a select element with the multiple attribute, but I cannot be sure. If so, this will work:
Code:
<script type="text/javascript">
function howMany(el){
for (var s = 0, i = el.options.length - 1; i > -1; --i)
if(el.options[i].selected) ++s;
return s;
}
</script>
<select id="mySel" multiple name="" onchange="alert(howMany(this));">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
<option value="">4</option>
<option value="">5</option>
</select><br>
<input type="button" onclick="alert(howMany(document.getElementById('mySel')));" value="How Many">
If you want more help, please show us the markup and code you are working with, or:
Please post a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks