SoonerNation
Programmer
I tried the solution offered in archived thread thread216-881568 but it doesn't seem to work for me.
Like the original poster, I have a master checkbox and need all other checkboxes in the form to set to the same value as the master, no matter their current value.
Any help is very much appreciated.
Lyndon
I copied the following script exactly:
<script type="text/javascript">
function checkAll(el) {
var isChecked = el.checked;
var form = el.form;
var els = form.elements;
for (var x = 0; x < els.length; x++) {
if (el != els[x]
&& els[x].type
&& els[x].type.toLowerCase() == "checkbox") {
// set to same state as master checkbox
els[x].checked = isChecked;
if (isChecked) {
// keep checked
els[x].onclick = function(){this.checked = true;}
}
else {
// normal behavior
els[x].onclick = null;
}
}
}
}
</script>
and used it in this context:
<form name="EMailList" action="EMailChecked.cfm" method="POST">
<tr>
<td class="ColumnHeadingCell" colspan="4">
<div align="Left"><input type="Checkbox" name="Master" onclick="checkall(this);"> All</div>
<div align="center">
<input type="submit" name="B1" value="EMail Checked">
<input type="reset" name="B2" value="Clear Checks">
</div>
</td>
</tr>
<tr>
<td class="ColumnHeadingCell">
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Name" class="InColumnHeader">Sort by Name</a>
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Department" class="InColumnHeader">Sort by Department</a>
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Location" class="InColumnHeader">Sort by Location</a>
</td>
</tr>
<cfoutput query="BinkleyUser">
<tr>
<td class="NormalCell">
<input type="Checkbox" name=#Trim(BinkleyUser.UserLogin)#>
</td>
<td class="NormalCell">
<cfset mName='Send email to '&Trim(BinkleyUser.FirstName)&' '&Trim(BinkleyUser.LastName)>
<a href="mailto:#BinkleyUser.EMail#" class="Special" title="#mName#">#UCase(BinkleyUser.FirstName)# #UCase(BinkleyUser.LastName)#</a>
</td>
<td class="NormalCell">
#UCase(BinkleyUser.Office)#
</td>
<td class="NormalCell">
#UCase(BinkleyUser.Location)#
</td>
</tr>
</cfoutput>
</form>
Like the original poster, I have a master checkbox and need all other checkboxes in the form to set to the same value as the master, no matter their current value.
Any help is very much appreciated.
Lyndon
I copied the following script exactly:
<script type="text/javascript">
function checkAll(el) {
var isChecked = el.checked;
var form = el.form;
var els = form.elements;
for (var x = 0; x < els.length; x++) {
if (el != els[x]
&& els[x].type
&& els[x].type.toLowerCase() == "checkbox") {
// set to same state as master checkbox
els[x].checked = isChecked;
if (isChecked) {
// keep checked
els[x].onclick = function(){this.checked = true;}
}
else {
// normal behavior
els[x].onclick = null;
}
}
}
}
</script>
and used it in this context:
<form name="EMailList" action="EMailChecked.cfm" method="POST">
<tr>
<td class="ColumnHeadingCell" colspan="4">
<div align="Left"><input type="Checkbox" name="Master" onclick="checkall(this);"> All</div>
<div align="center">
<input type="submit" name="B1" value="EMail Checked">
<input type="reset" name="B2" value="Clear Checks">
</div>
</td>
</tr>
<tr>
<td class="ColumnHeadingCell">
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Name" class="InColumnHeader">Sort by Name</a>
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Department" class="InColumnHeader">Sort by Department</a>
</td>
<td class="ColumnHeadingCell">
<a href="email.cfm?mOrder=Location" class="InColumnHeader">Sort by Location</a>
</td>
</tr>
<cfoutput query="BinkleyUser">
<tr>
<td class="NormalCell">
<input type="Checkbox" name=#Trim(BinkleyUser.UserLogin)#>
</td>
<td class="NormalCell">
<cfset mName='Send email to '&Trim(BinkleyUser.FirstName)&' '&Trim(BinkleyUser.LastName)>
<a href="mailto:#BinkleyUser.EMail#" class="Special" title="#mName#">#UCase(BinkleyUser.FirstName)# #UCase(BinkleyUser.LastName)#</a>
</td>
<td class="NormalCell">
#UCase(BinkleyUser.Office)#
</td>
<td class="NormalCell">
#UCase(BinkleyUser.Location)#
</td>
</tr>
</cfoutput>
</form>