:javascript
  function toggleBox(b, form, v){
    var form = document.forms[form];
    for(var i=0;i < form.length; i++){
      form.elements[i].checked = v;
    }
  }

%h1 table

- for slide,rows in @table.group_by{|r| r.values_at('slide').first}
  %p= "slide ===#{slide}==="
  %form(action="/" method="post" name="#{slide}")
    %input(type="hidden" name="slide" value="#{slide}")
    %input(type="submit" value="Send  slide:#{slide}" class="button")
    %input(type="button" value='selectAll' onclick="toggleBox(true, '#{slide}', 'checked') " )
    %input(type="button" value='selectNone' onclick="toggleBox(true, '#{slide}', '')" )    

    %table(border="1")
      %thread
        %tr
          - for header in @show_headers
            %th= header.to_s
      %tbody
        - for row in rows
          %tr
            - for cell in row.values_at(* @show_headers)
              %td= cell.to_s
            - lib_id = row.values_at('library_id')[0].to_s
            %td
              %input(type="checkbox" name="check[]" value="#{lib_id}")
            -if check_dir
              %td
                #exist= dir_exists?(slide, lib_id, row.values_at('prep_lit') ) 
                
:javascript
  function toggleBox(form, v){
    var f = document.forms[form];
    for(var i=0;i < f.length; i++){
      f.elements[i].checked = v;
    }
  }

%h1 table

- for slide,rows in @table.group_by{|r| r.values_at('slide').first}
  %p= "slide ===#{slide}==="
  %form(action="/" method="post" name="form-#{slide}")
    %input(type="hidden" name="slide" value="#{slide}")
    %input(type="submit" value="Send  slide:#{slide}" class="button")
    %input(type="button" value='selectAll' onclick="toggleBox(  'form-#{slide}', 'checked') " )
    %input(type="button" value='selectNone' onclick="toggleBox( 'form-#{slide}', '')" )    

    %table(border="1")
      %thread
        %tr
          - for header in @show_headers
            %th= header.to_s
      %tbody
        - for row in rows
          %tr
            - for cell in row.values_at(* @show_headers)
              %td= cell.to_s
            - lib_id = row.values_at('library_id')[0].to_s
            %td
              %input(type="checkbox" name="check[]" value="#{lib_id}")
            -if check_dir
              %td
                #exist= dir_exists?(slide, lib_id, row.values_at('prep_lit') ) 
                
FIX BUG, change form name so that ID-attribute begin with letter
FIX BUG, change form name so that ID-attribute  begin with letter
