Js to get the value selected in the checkboxlist
Function GetCheckBoxListValue (objID)
...{
Var v = new Array ();
Var CheckBoxList = document. getElementById (objID );
If (CheckBoxList. tagName = "TABLE ")
...{
For (I = 0; I <CheckBoxList. rows. length; I ++)
For (j = 0; j <CheckBoxList. rows [I]. cells. length; j ++)
If (CheckBoxList. rows [I]. cells [j]. childNodes [0])
If (CheckBoxList. rows [I]. cells [j]. childNodes [0]. checked = true)
V. push (CheckBoxList. rows [I]. cells [j]. childNodes [1]. innerText );
}
If (CheckBoxList. tagName = "SPAN ")
...{
For (I = 0; I <CheckBoxList. childNodes. length; I ++)
If (CheckBoxList. childNodes [I]. tagName = "INPUT ")
If (CheckBoxList. childNodes [I]. checked = true)
...{
I ++;
V. push (CheckBoxList. childNodes [I]. innerText );
}
}
Return v;
}
Asp.net Ajax version (dependent on Asp.net Ajax class library Support)
Function GetCheckBoxListValue (objID)
...{
Var v = new Array ();
Var CheckBoxList = $ get (objID );
If (CheckBoxList. tagName = "TABLE ")
...{
For (I = 0; I <CheckBoxList. rows. length; I ++)
For (j = 0; j <CheckBoxList. rows [I]. cells. length; j ++)
If (CheckBoxList. rows [I]. cells [j]. childNodes [0])
If (CheckBoxList. rows [I]. cells [j]. childNodes [0]. checked = true)
Array. add (v, CheckBoxList. rows [I]. cells [j]. childNodes [1]. innerText );
}
If (CheckBoxList. tagName = "SPAN ")
...{
For (I = 0; I <CheckBoxList. childNodes. length; I ++)
If (CheckBoxList. childNodes [I]. tagName = "INPUT ")
If (CheckBoxList. childNodes [I]. checked = true)
...{
I ++;
Array. add (v, CheckBoxList. childNodes [I]. innerText );
}
}
Return v;
}
Article Source: DIY tribe (http://www.diybl.com/course/1_web/javascript/jsjs/2008410/109123.html)