ELD
June 10th, 2009, 02:34 PM
Hi all i am finding a way to make it so ticking one box ticks them all kinda thing and i have this at the moment:
function checkUncheckAll(checkAllState, cbGroup)
{
// Check that the group has more than one element
if(cbGroup.length > 0)
{
// Loop through the array
for (i = 0; i < cbGroup.length; i++)
{
cbGroup[i].checked = checkAllState.checked;
}
}
else
{
// Single element so not an array
cbGroup.checked = checkAllState.checked;
}
}
Which is fine if the name is say "message" but my checkbox names are like "message[1]" or "message[15]" (a name array so php can sort the messages checked when it does the action, like deleting or saving the ticked ones).
How would i go about doing that? (Note i don't know javascript, this was from a rather small and undetailed tutorial).
function checkUncheckAll(checkAllState, cbGroup)
{
// Check that the group has more than one element
if(cbGroup.length > 0)
{
// Loop through the array
for (i = 0; i < cbGroup.length; i++)
{
cbGroup[i].checked = checkAllState.checked;
}
}
else
{
// Single element so not an array
cbGroup.checked = checkAllState.checked;
}
}
Which is fine if the name is say "message" but my checkbox names are like "message[1]" or "message[15]" (a name array so php can sort the messages checked when it does the action, like deleting or saving the ticked ones).
How would i go about doing that? (Note i don't know javascript, this was from a rather small and undetailed tutorial).