Did you ever find a solution to this? I am having a similar issue
without much luck of a solution. Have spent a few hours to no avail.
This is what I have found: When creating a CheckBoxList, at runtime it
is rendered as an HTML table. I, like you, need to get the value of
items checked, but am only receiving "on" for the value of all items,
checked or not. Looking at my source code of the rendered page, there
are no "Value" tags for the check boxes. I can get the "Label" value,
but that is a descriptive item; I need the value that I set in the
"DataValueField " at design time.
My CheckBoxList is named "cblist_facilit ies". I have a "Test" button
which calls the following code:
###
function Button1_onclick () {
var cblist = "cblist_facilit ies";
var chkList1= document.getEle mentById(cblist );
var arrayOfCheckBox es= chkList1.getEle mentsByTagName( "input");
var arrayOfCheckBox Labels= chkList1.getEle mentsByTagName( "label");
var listcount = arrayOfCheckBox es.length;
var displ="";
alert(listcount + " items in list.");
for(var i=0;i<arrayOfCh eckBoxes.length ;i++) {
displ= "" + (i+1) + ": " + arrayOfCheckBox es[i].checked + " - "
+ arrayOfCheckBox Labels[i].innerText;
alert(displ);
alert(arrayOfCh eckBoxes[i].value);
}
}
###
When run, the first alert correctly displays the number of checkboxes.
The second alert ("displ") correctly displays whether the checkbox is
checked or not and the correct descriptive label. However, the third
alert (...value) displays "on" for all checkboxes, checked or not.
Thoughts?
*** Sent via Developersdex
http://www.developersdex.com ***