"Select All" on Form checkboxes

Anyone have a way to add a "Select All" tick box on Form multichoice checkboxes?

Maybe there is some javascript for this?

I have seen some for tables, but not Forms.

Thanks

Hi Brad!  I tried to enter the code to create a "select all" option, but nothing happened.  I tried to look at the console log but really didn't know what I was looking for.  Do you know of a way to add a "select all" option that selects all items in a multiselect list?  Many thanks!!

Thanks Brad, 

Unfortunately I know nothing about java so will have to reply on others help ......

Cheers

Very elegant Stephen - Craig, maybe some console.log work to make sure firstly the $("#checkAll").click event is firing?

Then work through why $('input:checkbox').prop... isn't working.

I'd love this to work! 

Thanks for the reply Stephen!

I have only one multichoice checkbox, so no problems there.

However this code doesn't seem to work for me. I inserted it unchanged, but with no result. Any ideas?

Thanks

Hi Craig,

The below code works, however it would need refining if there is more than one multiple choice field in the form:

$(document).on('knack-scene-render.any', function (event, view, data) {
$("div.kn-checkbox").prepend("<input type='checkbox' id='checkAll' > Select All");
$("#checkAll").click(function(){
$('input:checkbox').prop('checked', this.checked);
});
});