[Javascript] select all checkboxes script

Michael Borchers list at tridemail.de
Fri Feb 3 04:24:35 CST 2006


i need a little skript to check or uncheck all checkboxes on button click.

the form name and / or the checkbox name should be parsed dynamically to the function

function checkAll(formName, checkboxName)

i tried to modify this function:
function CheckAll()
{
 if(document.form.ALL)
 {
  var c = document.form.ALL.checked;
 }
 for (var i=0;i<document.form.elements.length;i++)
 {
  var e = document.form.elements[i];

  if(e.name != 'ALL')
  {
   if((e.checked!=c) && (e.type=="checkbox"))
   {
    e.click();
     e.checked = c;
   }
  }
 }
}

but how can i parse the forms name?
how about modifying the function without using a form name,
only using the checkboxes name?

thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060203/2bcc30a4/attachment.htm>


More information about the Javascript mailing list