sunisagar
asked on
checkall for checkboxes in gridview
In my gridview I have a checkbox column , so, I have a check box as a header for that column.
The interaction part I want to use javascript. Does anyone have a good sample code for me ?
Thank you,
The interaction part I want to use javascript. Does anyone have a good sample code for me ?
Thank you,
This link is also very nice, and its for gridview control checkboxs.
http://weblog.vb-tech.com/nick/archive/2005/09/26/1300.aspx
function doAllChecks()
{
re = new RegExp('_chkMove')
if(document.Form1['Datagri d1_ctl1_ch kAction']. checked == true)
{
for (var iCount=0;iCount
{
elm = document.forms[0].elements [iCount]
if (elm.type == 'checkbox') {
if (re.test(elm.id)) {
elm.checked = true;
}
}
}
}
else
{
for (var iCount=0;iCount
{
elm = document.forms[0].elements [iCount]
if (elm.type == 'checkbox') {
if (re.test(elm.id)) {
elm.checked = false;
}
}
}
}
}
http://weblog.vb-tech.com/nick/archive/2005/09/26/1300.aspx
function doAllChecks()
{
re = new RegExp('_chkMove')
if(document.Form1['Datagri
{
for (var iCount=0;iCount
{
elm = document.forms[0].elements
if (elm.type == 'checkbox') {
if (re.test(elm.id)) {
elm.checked = true;
}
}
}
}
else
{
for (var iCount=0;iCount
{
elm = document.forms[0].elements
if (elm.type == 'checkbox') {
if (re.test(elm.id)) {
elm.checked = false;
}
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
http://www.shiningstar.net/articles/articles/javascript/checkboxes.asp
<SCRIPT LANGUAGE="JavaScript">
<!--
// by Nannette Thacker
// http://www.shiningstar.net
// This script checks and unchecks boxes on a form
// Checks and unchecks unlimited number in the group...
// Pass the Checkbox group name...
// call buttons as so:
// <input type=button name="CheckAll" value="Check All"
//onClick="checkAll(docume
// <input type=button name="UnCheckAll" value="Uncheck All"
//onClick="uncheckAll(docu
// -->
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
// End -->
</script>