Re: Check/Uncheck all checkbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually it does work whether you have 1, 3 or 100 checkboxes since document.getElementsByName() always returns an array.

Alligator_666


aslam doctor <aslam.doctor@xxxxxxxxx> wrote:                             try the Alligator's script with single checkbox, i guess it will not work.
 
 On Fri, Sep 26, 2008 at 8:17 PM, Alligator <alligator_666@xxxxxxxxx> wrote:
 
 > Try something like this:
 >
 >        <script type='text/javascript'>
 >        <!--
 >            function MyCheck(ctrlCheck, checkListName)
 >            {
 >                var chBoxes = document.getElementsByName(checkListName);
 >                for (i = 0; i < chBoxes.length; i++)
 >                    chBoxes[i].checked = ctrlCheck.checked ;
 >            }
 >        //  -->
 >        </script>
 >
 >
 >        <form>
 >            <input type="checkbox" name="Check_ ctr" value="yes"
 > onClick="MyCheck(this, 'check_list[]')" /><b> Check Control</b>
 >             <br /><br />
 >            <input type="checkbox" name="check_list[]" value="3"/>hello1<br>
 >            <input type="checkbox" name="check_list[]" value="4"/>hello2<br>
 >            <input type="checkbox" name="check_list[]" value="5"/>hello3<br>
 >        </form>
 >
 >
 >
 > In this case I pass two parameters to the JS function:
 > 1.- The Control CheckBox
 > 2.- The NAME of the CheckBoxes I want to check/uncheck uppon clicking the
 > control box.
 >
 > Hope this helps
 >
 >
 > Alligator_666
 >
 >
 > Sabs <s.rahman@xxxxxxxxxxxx> wrote:                             Hi
 > everyone,
 >  I know this is not the appropriate list for this question, but I was just
 >  wondering if there's anyone in this list that can help me out here...
 >
 >  I want a checkbox that checks/unchecks all the other checkbox below it....
 >  the following code works fine.... but If I replace the name of the
 >  checkbox as an array (i.e. from 'check_list' to 'check_list[]' ) it doesnt
 >  work....
 >  I would really appreciate if anyone can help me out...
 >
 >  Here is my code:
 >
 >  ====================================================================
 >  ====================================================================
 >  <script language="javascript">
 >  <!--
 >
 >  function MyCheck(chk)
 >  {
 >  if(document.myform3.Check_ctr.checked==true){
 >  for (i = 0; i < chk.length; i++)
 >  chk[i].checked = true ;
 >  }else{
 >
 >  for (i = 0; i < chk.length; i++)
 >  chk[i].checked = false ;
 >  }
 >  }
 >
 >  //  End -->
 >  </script>
 >
 >  <form name="myform3" action="checkboxes.asp" method="post">
 >  <input type="checkbox" name="Check_ctr" value="yes"
 >  onClick="MyCheck(document.myform3.check_list)"><b>Check Control</b>
 >  <br /><br />
 >  <input type="checkbox" name="check_list" value="3">hello1<br>
 >  <input type="checkbox" name="check_list" value="4">hello2<br>
 >  <input type="checkbox" name="check_list" value="5">hello3<br>
 >
 >  </form>
 >
 >  =====================================================================
 >  =====================================================================
 >
 >  thanks a lot for your help in advance..........
 >
 >  best
 >  _sabs
 >
 >  > do u meant paging in php??? ...
 >  >
 >  >
 >  >
 >  >
 >  > Thanks,
 >  >
 >  > Â Â Â Â  Reji,
 >  > Â Â Â Â  PHP Developer.
 >  >
 >  >
 >  >
 >  >
 >  > --- On Wed, 24/9/08, embroidtiger2008 <moinrazzaq@xxxxxxxxx> wrote:
 >  > From: embroidtiger2008 <moinrazzaq@xxxxxxxxx>
 >  > Subject:  How to make dynamic pagess in php??
 >  > To: php-objects@xxxxxxxxxxxxxxx
 >  > Date: Wednesday, 24 September, 2008, 7:23 PM
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >             How to make dynamic pages in php??
 >  >
 >  >
 >  >
 >  > Any prctical example or or tutorial, plz guide me.
 >  >
 >  >
 >  >
 >  > MOIN
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >
 >  >       Unlimited freedom, unlimited storage. Get it now, on
 >  > http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
 >  >
 >  > [Non-text portions of this message have been removed]
 >  >
 >  >
 >
 >
 >
 >
 >
 >
 >
 > [Non-text portions of this message have been removed]
 >
 >
 > ------------------------------------
 >
 > Are you looking for a PHP job? Join the PHP Professionals directory Now!
 > http://www.phpclasses.org/professionals/Yahoo! Groups Links
 >
 >
 >
 >
 
 -- 
 A.M.Doctor
 
 [Non-text portions of this message have been removed]
 
 
     
                                       

       

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux