Check/uncheck all checkboxes

Hello!

I have this page where I list all users in a table. There is checkbox in
every row. My User-model has a “checked”-attribute.

I have implemented the checkboxes like this:
<%= check_box(“user[]”, “checked”) %>

Which outputs this:

How can i check/uncheck all checkboxes in one click? Do I have to use
javascript and have onClick()-event?

use an onclick for a button or something and send the form thru this

function checkAll(theForm) {

var z = 0;

while (theForm[z].type == ‘checkbox’ ) {
theForm[z].checked = true;
z++;
}
}

adam