Hello All,
I have a CF template wherein I have a list of checkboxes. The parent Checkboxe is the department and below that is the list of employees. If the user selects the parent checkbox then all the checkboxes below it should get selected. It is not giving me any error but the length of the employee checkboxes is coming up as zero. I checked all the boxes have the same name.
The Coldfusion code:
<tr><td>
<strong>#Department#</strong>
<input type="checkbox" id="#DepartmentID##PermID#" style="cursorointer" onclick="SelectAll(this.id)">
<table id="DeptRow#ctr##PermID#" style="display:none;">
<cfloop query="GetEmployees">
<tr>
<td>#GetEmployees.Firstname#
<input type="checkbox" id="Chk#DepartmentID##PermID#" name="Chk#DepartmentID##PermID#" style="cursorointer">Chk#DepartmentID##PermID#</td>
</tr>
</cfloop>
THE JAVASCRIPT CODE:
function SelectAll(DeptID){
var chkbox = "Chk" + DeptID;
var cboxes = document.all.frmAddEdit.getElementsByTagName(chkbox);
if (typeof(cboxes) != 'undefined'){
for (i = 0; i < cboxes.length; i++)
cboxes.checked = true ;
}
}
Thanks for the help in advance.
I have a CF template wherein I have a list of checkboxes. The parent Checkboxe is the department and below that is the list of employees. If the user selects the parent checkbox then all the checkboxes below it should get selected. It is not giving me any error but the length of the employee checkboxes is coming up as zero. I checked all the boxes have the same name.
The Coldfusion code:
<tr><td>
<strong>#Department#</strong>
<input type="checkbox" id="#DepartmentID##PermID#" style="cursorointer" onclick="SelectAll(this.id)">
<table id="DeptRow#ctr##PermID#" style="display:none;">
<cfloop query="GetEmployees">
<tr>
<td>#GetEmployees.Firstname#
<input type="checkbox" id="Chk#DepartmentID##PermID#" name="Chk#DepartmentID##PermID#" style="cursorointer">Chk#DepartmentID##PermID#</td>
</tr>
</cfloop>
THE JAVASCRIPT CODE:
function SelectAll(DeptID){
var chkbox = "Chk" + DeptID;
var cboxes = document.all.frmAddEdit.getElementsByTagName(chkbox);
if (typeof(cboxes) != 'undefined'){
for (i = 0; i < cboxes.length; i++)
cboxes.checked = true ;
}
}
Thanks for the help in advance.