title: javascript select all checkboxes in a table
body: <p>I want to make a page that has a table of various webpages with checkboxes next to each. I want the user to be able to select multiple sites then search the sites using a google bar. I have a table where each cell has a form filled with checkboxes. each cell has a checkall button that checks all the options in that cell. I would like to add a checkbox to select all the options on the page. (yes I could just leave this option out but I kind of want to know how to access all the boxes in the cells anyway so that I can search with google like I want.) here is basically what I have. Its the section inside checkPage function that needs help at this point</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
      function checkAll(checkname, bx) {
          for (i = 0; i &lt; checkname.length; i++){
              checkname[i].checked = bx.checked? true:false;
          }
      }
      function checkPage(bx){
  
  
          var bxs = document.getElementByTagName ( "table" ).getElementsByTagName ( "link" ); 
  
          for(i = 0; i &lt; bxs.length; i++){
              bxs[i].checked = bx.checked? true:false;
          }
      }
  &lt;/script&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;input type="checkbox" name="pageCheck"  value="yes" onClick="checkPage(this)"&gt;&lt;b&gt;Check Page&lt;/b&gt;
  &lt;table border="1" name ="table"&gt;
  
  &lt;tr&gt;
      &lt;td name ="list00"&gt;
          &lt;form name ="list00"&gt;
              &lt;input type="checkbox" name="Check_ctr" value="yes" onClick="checkAll(document.list00.link, this)"&gt;&lt;b&gt;Check All&lt;/b&gt;&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;
          &lt;/form&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;form name ="list01"&gt;
              &lt;input type="checkbox" name="Check_ctr" value="yes" onClick="checkAll(document.list01.link, this)"&gt;&lt;b&gt;Check All&lt;/b&gt;&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;      
          &lt;/form&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;form name ="list10"&gt;
              &lt;input type="checkbox" name="Check_ctr" value="yes" onClick="checkAll(document.list10.link, this)"&gt;&lt;b&gt;Check All&lt;/b&gt;&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;  
          &lt;/form&gt;&lt;/td&gt;
      &lt;td&gt;&lt;form name ="list11"&gt;
              &lt;input type="checkbox" name="Check_ctr" value="yes" onClick="checkAll(document.list11.link, this)"&gt;&lt;b&gt;Check All&lt;/b&gt;&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;
              &lt;input type="checkbox" name="link" value="something.com"&gt;something.com&lt;dd&gt;  
          &lt;/form&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>