Re: Check/Uncheck all checkbox

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

 



Hi,

Use the following code:
the changes done in previous codes are:

1. while calling javascript function send (this) as parameter.
2. Javascript function code is changed. Now using the elemnet checking.

<form name="myform3" action="" method="post">
<input type="checkbox" name="Check_ctr" value="yes"
onClick="MyCheck(this)"><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>
<input type="submit" value="submit" name="sub" />
</form>

<script language="javascript">


function MyCheck(chk)
{
    var elm=document.myform3.elements;

    for(i=0;i<elm.length;i++)
    {
        if(elm[i].type=="checkbox")
        {
            elm[i].checked = chk.checked;

        }
    }
}
</script>

This will work fine.

Thanks & Regards
Neeraj Jain
Senior PHP Developer


On Thu, Sep 25, 2008 at 8:16 PM, 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<moinrazzaq%40gmail.com>>
> wrote:
> > From: embroidtiger2008 <moinrazzaq@xxxxxxxxx <moinrazzaq%40gmail.com>>
> > Subject:  How to make dynamic pagess in php??
> > To: php-objects@xxxxxxxxxxxxxxx <php-objects%40yahoogroups.com>
> > 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]


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

  Powered by Linux