Hi Alexander:
Further to your Multiple Choice Checkbox solution, do you know of a way to add a “Select All” to all checkboxes on an entire form?Thanks-
Charlie Epes
Add this code to a CEWP below the form in NewForm or EditForm: Alter the reference to jQuery if necessary.
<script type="text/javascript" src="../../Javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
/* Add "Invert", "Check all" and "Uncheck all" to a multichoice checkbox column, or a Yes/No column
* Created by Alexander Bautz
* alexander.bautz@gmail.com
* http://spjsblog.com
* v1.0
* LastMod: 25.02.2010
*
*/
// Initialt all fields
fields = init_fields();
// To insert a control above a specific field call with the fieldinternalname as argument
init_toggleAll('MyMultiChoice');
// To insert a control above the formtable and control all checkboxes in the form, call with no argument
init_toggleAll();
function init_toggleAll(FieldInternalNameOrEmpty){
str = "<span title='Invert selection' style='cursor:pointer' onclick='javascript:toggleAll($(this),"invert")'>Invert</span> | " +
"<span title='Check all' style='cursor:pointer' onclick='javascript:toggleAll($(this),"check")'>All</span> | " +
"<span title='Uncheck all' style='cursor:pointer' onclick='javascript:toggleAll($(this),"uncheck")'>None</span>";
if(fields[FieldInternalNameOrEmpty]==undefined){
obj=$("table.ms-formtable");
obj.before("<div style='font-size:10px;padding-top:5px'>"+str+"</div>");
}else{
obj=$(fields[FieldInternalNameOrEmpty]).find('.ms-formbody');
obj.prepend("<div style='font-size:10px'>"+str+"</div>");
}
}
function toggleAll(obj,action){
obj.parent().parent().find('input:checkbox').each(function(){
if(action=='invert'){
if($(this).attr('checked')==false){
$(this).attr('checked',true);
}else{
$(this).attr('checked',false);
}
}else if(action=='check'){
$(this).attr('checked',true);
}else if(action=='uncheck'){
$(this).attr('checked',false);
}
});
}
function init_fields(){
var res = {};
$("td.ms-formbody").each(function(){
if($(this).html().indexOf('FieldInternalName="')<0) return;
var start = $(this).html().indexOf('FieldInternalName="')+19;
var stopp = $(this).html().indexOf('FieldType="')-7;
var nm = $(this).html().substring(start,stopp);
res[nm] = this.parentNode;
});
return res;
}
</script>
Other similar articles:
- Limit number of allowed selections in Checkboxes choice
- Multiple default values in a column of type “Checkboxes”
Regards
Alexander



You had to one up me. lol, great job!
Hi,
I wanted to make a solution that did not require a “select all” option in the field itself.
Alexander
!!!!!!! I’m happy today! Thank you -
Charlie Epes
Hey A, been a while, hope you are well. Quick qusetion, I am using this script with the wrapchoice. The “Invert | All | None” text is displaying at the bottom of the choices. I cannot get it to default to the top. When I moved it over to the label column it defaults to either above or below the field Name, but never next to it.
How can I get the text to display in the same location as the scripts defaults when using it with your wrapchoice script?
Brilliant – this is exactly what I needed.
So Alexander, got to bug you again. Is there a way to apply this functionality to Yes/No fields in a way that I have a group of them, click Select all and they are checked?
I have an intake, for simplicity reasons we can use regions and countries. If the user needs to check all the Yes/No country fields for one reagion, is there a way to make this work, and only work on the predetermined fields selected or assigned for that region?
thanks again for all you do here.
i had all three scripts related to checkboxes together as i had 98 selection values- dependent selections, wrap choice and check all
worked great!