Resources » TypeScript » Scripting Languages » Javascript

CheckBox SelectAll / DeSelectAll using Javascript...?


Posted Date: 18-Jul-2013  Last Updated:   Category: Javascript    
Author: Member Level: Diamond    Points: 15


In this artical i'm trying to explain CheckBox SelectAll and DeSelectAll. In my page header itself i have a CheckBox Control once i click on that header checkbox all checkboxes in DataRow need to checked. Again i click on Header Checkbox need to deselect all checkboxes.



CheckBox SelectAll / DeSelectAll



In this artical i'm trying to explain how to select all checkboxes and how to deselect all checboxes using single click.
For this i'm introducing Javascript function using this javascript function easy to select all checkboxes and deselect all checkboxes and call that javascritp function in control itself.

JavaScript



for Select and DeSelect All CheckBoxes purpose i wrote some javascript function. Use below lines of code.



< script type="text/Javascript" >

function Check(parentChk,container)
{
var elements = document.getElementsByTagName("INPUT");
for(i=0; i {
if(parentChk.checked == true)
{
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id,container))
{
elements[i].checked = true;
}
}
else
{
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id,container))
{
elements[i].checked = false;
}
}
}
}
< script>


Source code



Call that Javascript function in header control checkbox.



<asp:GridView ID="GV" runat="server" ShowFooter="false" Width="100%"
EnableModelValidation="True" ForeColor="#333333"
GridLines="Vertical" AutoGenerateColumns="false" >

<Columns>
<asp:TemplateField >
<HeaderTemplate>
<input id="HchkSelect" type="checkbox" onclick="javascript:Check(this,'GV');" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
</Columns>
</asp:GridView>


Select/Deselect All


Did you like this resource? Share it with your friends and show your love!

Responses to "CheckBox SelectAll / DeSelectAll using Javascript...?"
Guest Author: Arecg     19 Sep 2013
When you watch the Texans’ DE play, its easy to be impressed with his athletic ability, speed up the field and his power at the point of attack. That’s legit talent right there. But let’s not forget about the technique Watt displays with his hands. He can “press” an offensive lineman and create some separation to work his counter moves. Fast and violent with the hands. That’s what I took from the game. CSS10-26


Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    samaira
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India