title: How to select all rows into table
body: <p>I have a HTML table with pagination. I use this JavaScript to select all rows into the table:
  Main checkbox:</p>
  
  <pre><code>&lt;h:column id="selection_column"&gt;
      &lt;f:facet name="header"&gt;
           &lt;h:selectBooleanCheckbox class="checkall"/&gt;
      &lt;/f:facet&gt;
  &lt;/h:column&gt;
  </code></pre>
  
  <p>The JavaScript code:</p>
  
  <pre><code>$(window).load(function () {
          $(document).delegate(".checkall", "click", function(event) {
                $(this).closest("table").find(':checkbox').attr('checked', this.checked);
          });
      });
  </code></pre>
  
  <p>The problem is that when I use it only the rows into the first page are selected. The rows into the second page and so on are not selected. How I can fix this?</p>
  
  <p>EDIT</p>
  
  <p>I have an idea but I don't know is it going to work: I can create a checkbox(lets call it main checkbox) which when it's selected all rows are selected. I tested it - once selected this checkbox is always selected when I shift the pages. But I need a JavaScript code which checks during load time if the main checkbox is selected then all checkboxes are selected. Can you help me to rewrite the JavaScritp this way, please?</p>