I’m running into some type of error here. Nothing is happening. Does anyone have idea idea why?
Thank you beforehand!
-form_tag :action => 'form', :name =>'admin_form' do
#images_actions_bar
.select_all
=check_box_tag('check_all', 'check_all', false, :onClick => "$$('admin_form input.check').each(function(box){box.checked=true});return false;")
==============
thanks. what ultimately worked for me was a check box like this:
=check_box_tag('check_all', 'check_all', false, :onClick => "checkAll(document.admin_form.check_all, document.admin_form.checkbox);")
and a js function like this:
function checkAll(field_main, fields){
if(field_main.checked == true){
for (i = 0; i < fields.length; i++)
fields[i].checked = true ;
}else{
for (i = 0; i < fields.length; i++)
fields[i].checked = false;
}
It’s not clear what javascript framework you’re using. I’ve really only used jQuery and (minimally) Prototype. So, I’d check that
admin_formis selecting the form element properly. In jQuery, it would have to beform[name="admin_form"]I’ve modified a check/uncheck all jquery piece that I previously wrote. Hopefully it may help. First, clicking “check_all” will check all checkboxes. Clicking a checkbox will then uncheck the “check_all” checkbox.