0

Hi Everyone,
i have a query regarding checkboxes.
i have got a 'check all' checkbox on my form but what i need is to uncheck all if the check all is not checked

This is the check all script

function checkAll(field) {
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}

and i'm calling it via

<input type="checkbox" name="CheckAll" onclick="checkAll(document.myform['delete[]'])" />

Any help would be great.

Cheers...

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by scaiferw
0

you can try this

function checkAll(field) {
if(document.myform.CheckAll.checked)
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}
else
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}
}
0

you can try this

function checkAll(field) {
if(document.myform.CheckAll.checked)
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}
else
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}
}

Thanks for the reply,
Unfortunatly that didn't work but not to worry, i managed to find a code that did work for me. Thanks for taking the time.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.