Contact Us

|

FriendFeed FriendFeed

|

follow us on twitter Twitter

|

 Rss Feed

|

Favorites Add to Favorites

Thursday, March 10, 2011

Toggle select and unselect checkbox with text

Here is a simple javascript to toggle between selected and unselected of a checkbox. And also it will toggle the text, for example when you click on the select link the text will change to unselect and the vise-verse...


function ToggleCheckBox()
{
var ischecked=document.getElementsByTagName("input");
var divid=document.getElementById('id name');
for(i=0;i<ischecked.length;i++)
{
if(ischecked[i].type == "checkbox")
{
if(ischecked[i].checked == true)
{
divid.innerHTML="Select All";
ischecked[i].checked=false;
}
else
{
divid.innerHTML="Deselect All";
ischecked[i].checked=true;
}
}
}

}

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home