LyndonOHRC
Programmer
I'm working on a form that has a master checkbox on a table heading and one dynamically created checkbox next to every name in a database query. I'm trying to create a mailing list and want the master checkbox to check/uncheck all, then allow the user to remove some checks if desired.
I'm using a routine found in another thread to check/uncheck all checkboxes on a form. When the inputs are unchecked the user can check/uncheck any box on the form. However, if they are all dynamically set to checked then the user can't uncheck them???
Any idea what I'm missing?
checkall script:
html:
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
I'm using a routine found in another thread to check/uncheck all checkboxes on a form. When the inputs are unchecked the user can check/uncheck any box on the form. However, if they are all dynamically set to checked then the user can't uncheck them???
Any idea what I'm missing?
checkall script:
Code:
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;
}
}
}
}
html:
Code:
<form name="mailbox" method="post" enctype="text/plain">
<tr>
<td class="ColumnHeadingCell">
<input type="Checkbox"
id="cbMaster"
title="Change All Mail Checks"
onclick="checkAll(this);"
</td>
<td class="ColumnHeadingCell" style="text-align: center;">
ORI Membership
</td>
</tr>
<cfoutput query="GetMembers">
<tr style="background-color: white;">
<td>
<input type="Checkbox"
name="#GetMembers.index#"
title="Include In Current Mail List">
</td>
<td>
#LCase(GetMembers.FirstName)# #LCase(GetMembers.LastName)#
</td>
</tr>
</cfoutput>
</form>
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey