Skip to main content

Select all and None using javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

   <script language="javascript" type="text/javascript">
function Select(Select)
{
for (var n=0; n < document.forms[0].length; n++)
if (document.forms[0].elements[n].type=='checkbox')
document.forms[0].elements[n].checked=Select; return false;
}
   </script>

   <title>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
       <div>
           <asp:CheckBoxList ID="CheckBoxList1" runat="server">
           </asp:CheckBoxList>
       </div>
       Select <a href="#" onclick="javascript:Select(true)">All</a> | <a href="#"
onclick="javascript:Select(false)">
           None</a>
       <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
   </form>
</body>
</html>

Comments

Popular posts from this blog