How to count the number of listitems in an asp.bulletedlist with JavaScript

Posted by Andy5 on Stack Overflow See other posts from Stack Overflow or by Andy5
Published on 2010-03-12T17:02:27Z Indexed on 2010/03/12 17:07 UTC
Read the original article Hit count: 177

Filed under:
|
|

Hi

I have an asp:bulletedlist control, which sits inside a div tag, and I need to count the number of list items inside the control. Searching the internet, and noting the fact the html given back by the items is a list i.e. <li>, I thought I could use an example of:

var listcontrol = document.getElementById('BulletedList1');
var countItems = listcontrol.getElementByTagName('li').length;

However, when I do this, it throws and error saying that no object exists for this control.

So, my problem is, and because I must do this clientside because I want to use this to set the height of the div tag, is how do you count the number of items inside a asp:bulletedlist control with javascript?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about bulletedlist