for loops my friend.
for(count = 1;box = document.getElementById(cur_id);count++) { box.checked = setting; cur_id = id+count; }
also, jquery.
function toggleAll(id) { $("[id^="+id+"]:checkbox").attr('checked', true);}
same sht as yours.