Check boxes check all tips

Hi,

Pardon me if this question is already asked. I wonder if anyone know
where I can find the snippet of code that will allow me to do “check
all” and “uncheck all” in a list view of items. I am trying to see if
there is any rails api i can use instead of “raw” javascript. Thanks in
advance.

Regards,
Chester

pass it the form id and true/false and this should do it:

function toggleCheck (form_id, checked) {
var form = $(form_id);
for (var i = 0; i < form.elements.length; i++) {
form.elements[i].checked = checked;
}
}

On 9/14/06, Chester C. [email protected] wrote:

Regards,
Chester


Posted via http://www.ruby-forum.com/.


Ed Hickey
Developer
Litmus Media
816-533-0409
[email protected]
A Member of Think Partnership, Inc
www.ThinkPartnership.com
Amex ticker symbol: THK

This should select and check all the inputs in the element with id
#container
to uncheck them, just change the checked to false

<%=link_to_function "Select All", update_page {|page|

page.select(’#container input’).each {|x|x.checked = true}}%>

e.g this will check the following checkboxes

i love ruby i love rails

Hope this helps!

Cheery-O!
Gustav
[email protected]
itsdEx.com