Check All And Toggle Check Box (s) ?
how to make check all and toggle check boxes, here s the easy and effective script.
just rock.
<!-- Copy and Paste below script -->
<title>Check All And Toggle Check Boxes</title>
<body>
<script type=text/javascript >
function all(source)
{
checkboxes = document.getElementsByName('list[]');
for each(var checkbox in checkboxes)
checkbox.checked = source.checked;
}
function toggle(source)
{
checkboxes = document.getElementsByName('list[]');
for each(var checkbox in checkboxes)
{
if (checkbox.checked == true)
{ checkbox.checked = false;
}
else { checkbox.checked = true;
}
}
}
</script>
<fieldset>
<legend>Categories View : </legend>
<table border="1" class="hovertable">
<form Action='delcate' method='post' name=myform>
<tr>
<th><INPUT type='checkbox' onClick="all(this)" name=checkAll>All</th>
<th><INPUT type='checkbox' onClick="toggle(this)" name=Toggle>Toggle</th>
<th><a href='http://localhost/cakephp/index.php/categories/newcate'>Add new</a></th>
<th></th>
<th></th>
</tr>
<tr>
<th><input type=Submit value=Del></th>
<th>Id</th>
<th>Cate Title</th>
<th>Cate Desc</th>
<th>Edit</th>
</tr>
<!-- Here is where we loop through our $posts array, printing out post info -->
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td><input type=checkbox name='list[]' value='1' ></td>
<td>1</td>
<td>Food Catego</td>
<td>cate descriptions 01</td>
<td><a href='http://localhost/cakephp/index.php/categories/editcate/1' > edit</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td><input type=checkbox name='list[]' value='2' ></td>
<td>2</td>
<td>Product Catego</td>
<td>cate descriptions 02</td>
<td><a href='http://localhost/cakephp/index.php/categories/editcate/2' > edit</td>
<tr>
<th><input type=Submit value=Del></th>
<th>Id</th>
<th>Cate Title</th>
<th>Cate Desc</th>
<th>Edit</th>
</tr>
</table>
</fieldset>
</body>
<!-- script ends -->
Check All And Toggle Check Boxes
0 comments:
Post a Comment
Any Questions or Suggestions ?