You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Goldy J <go...@yahoo.com> on 2003/08/13 18:48:32 UTC

Checkall for Multibox--pls. help

Hello,
 
I have a JSP in which I show number of records in a table. Each row has a checkbox associated with it. All the valid records has to be checked by default. I have been able to do so using MULTIBOX using TED's famous tip. 
 
My problem is that the client wants a checkbox at the top , click of which should select all the checkbox and unselect of which should unselect all in one go ..something similar to yahoo mail .. 
 
Tried to do some stuff but failed. Can some one help and let me know if it is at all possible to do so with multibox ..if  yes how??
 
Thanks in advance


---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

RE: Checkall for Multibox--pls. help

Posted by Mike Jasnowski <mj...@bea.com>.
Yes it is possible, I'm not using multibox, but the same logic applies:

function checkAll(cAll){
    var cbs = document.forms[0].elements['" + checkBoxNamePrefix + "'];
    if (typeof cbs.length == \"undefined\") {
        cbs = document.forms[0]." + checkBoxNamePrefix + ";
        if (cAll.checked " + andOps + " !cbs.checked) cbs.checked = true; if
(!cAll.checked && cbs.checked) cbs.checked = false;
            return;
        }
            for (var i=0;i<cbs.length;i++)
                if (cbs[i].checked && !cAll.checked) cbs[i].checked = false;
            else (cbs[i].checked) = true;");
}

function unCheck(item){");
 if (!item.checked) document.forms[0].all.checked = false;
     else {
          var cbs = document.forms[0].elements['" + checkBoxNamePrefix +
"'];
               for (var i=0;i<cbs.length;i++) {
                 if (!cbs[i].checked) return false;
              }
            document.forms[0].all.checked = true;
 }

if the formatting is off I apologize, I cut this out of some code and
reformatted for email.  The checkAll function is for the top-level box, and
the unCheck() item is for an individual item.  The variable part is the
"checkboxNameprefix" which is supplied when the tag this comes from renders
the set of checkboxes.  If you need more info let me know.

-----Original Message-----
From: Goldy J [mailto:goldy0906@yahoo.com]
Sent: Wednesday, August 13, 2003 12:49 PM
To: struts-user@jakarta.apache.org
Subject: Checkall for Multibox--pls. help


Hello,

I have a JSP in which I show number of records in a table. Each row has a
checkbox associated with it. All the valid records has to be checked by
default. I have been able to do so using MULTIBOX using TED's famous tip.

My problem is that the client wants a checkbox at the top , click of which
should select all the checkbox and unselect of which should unselect all in
one go ..something similar to yahoo mail ..

Tried to do some stuff but failed. Can some one help and let me know if it
is at all possible to do so with multibox ..if  yes how??

Thanks in advance


---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org