Tuesday, April 12, 2011

Loop through checklistbox items using Javascript

I was almost loosing my patience when I did'nt get the items of checkboxlist using javascript in Mozilla Firefox

I got the items in internet explorer by using the table approach and fetching the items of table, but there was a problem with firefox so got this solution.


var elementRef=document.getElementById("<%=chkListNOs.ClientID%>");
var checkBoxArray = elementRef.getElementsByTagName('input');

for (var i=0;i {
var listControl = checkBoxArray[i];
if(listControl.type =="checkbox")
if ( listControl.checked == true )
{

isChecked=true;
}

}

Hope this helps.
Enjoy

No comments: