Tim Maxey .NET Technology Blog & Resources
April 2009 Entries
Ok I needed a function that would select certain CheckBoxList items of an ASP.NET CheckBoxList, so here it is, hope is helps someone else out!
if you want I use this function hightlight the item in yellow:
function uStyle(cb) {
cb.parentNode.style.backgroundColor = cb.checked ? "yellow" : "";
cb.parentNode.style.color = cb.checked ? "blue" : "";
}
function doCertainOnes(cbControl) {
var chkBoxList = document.getElementById(cbControl);
var chkBoxCount = chkBoxList.getElementsByTagName("input");
chkBoxCount[5].checked = true;
chkBoxCount[5].focus(); //GOING TO JUMP DOWN IN THE LIST TO THE FIRST SELECTED
uStyle(chkBoxCount[5]);
chkBoxCount[6].checked = true;
uStyle(chkBoxCount[6]);
chkBoxCount[7].checked = true;
uStyle(chkBoxCount[7]);
for (var i = 10; i < 50; i++) {
chkBoxCount[i].checked = true;
uStyle(chkBoxCount[i]);
...