Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Craig Spurrier craigweb.net

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Check/Uncheck all checkboxes based on one check box

Bassed on http://www.bigbold.com/snippets/posts/show/350
   1  
   2  <html>
   3    <head>
   4      <script language='JavaScript'>
   5        checked = false;
   6        function checkedAll () {
   7          if (checked == false){checked = true}else{checked = false}
   8  	for (var i = 0; i < document.getElementById('myform').elements.length; i++) {
   9  	  document.getElementById('myform').elements[i].checked = checked;
  10  	}
  11        }
  12      </script>
  13    </head>
  14    <body>
  15      <form id="myform">
  16        <input type="checkbox" name="foo"/>
  17        <input type="checkbox" name="bar"/>
  18        <BR>Check all: <input type='checkbox' name='checkall' onclick='checkedAll();'>
  19      </form>
  20    </body>
  21  </html>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS