Geeks With Blogs
Gaurav Taneja Great dreams... never even get out of the box. It takes an uncommon amount of guts to put your dreams on the line, to hold them up and say, "How good or how bad am I?" That's where courage comes in.

Javascript Function for Select All CheckBox functionality.. 

 

<script language="javascript" type="text/javascript">

function SelectAll(CheckBoxControl)

        {

        var ctrlName;

        if (CheckBoxControl.id=='chkAllLocation')

        {

        ctrlName="chkLocations";

        }

    

            if (CheckBoxControl.checked == true)

            {           

            var i;

                for (i=0; i < document.forms[0].elements.length; i++)

                {

                    if ((document.forms[0].elements[i].type == 'checkbox') &&

                    (document.forms[0].elements[i].name.indexOf('grdLocation') > -1) )

                    {

                   

                        var str = new String(document.forms[0].elements[i].name);

                        str = str.match(ctrlName);

                        if (str!=null)

                        {

                     if (str.length > 0)

                        document.forms[0].elements[i].checked = true;

                        }

                    }

                }

            }

            else

            {

                var i;

                for (i=0; i < document.forms[0].elements.length; i++)

                {

                    if ((document.forms[0].elements[i].type == 'checkbox') &&

                    (document.forms[0].elements[i].name.indexOf('grdLocation') > -1))

                    {

                      var str = new String(document.forms[0].elements[i].name);

                        str = str.match(ctrlName)

                         if (str!=null)

                        {

                     if (str.length>0)

                        document.forms[0].elements[i].checked = false;

                        }

                    }

                }

            }

        }

     </script>

CS CODE

---------------------------------------------------------------------

<radg:GridTemplateColumn>

 <ItemTemplate>

     <asp:CheckBox ID="chkLocations" runat="server"  AutoPostBack="false"  EnableViewState="True" />

 </ItemTemplate>

 <HeaderTemplate>

       <input type="checkbox" id="chkAllLocation" onclick="SelectAll(this);"/>Copy?

  </HeaderTemplate>

 <ItemStyle Width="15%" />

</radg:GridTemplateColumn>

Posted on Thursday, April 3, 2008 8:05 PM Vini | Back to top


Comments on this post: Javascript Function for Select All CheckBox functionality..

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Gaurav Taneja | Powered by: GeeksWithBlogs.net