Looking For Anything Specific?

Select all check box using one check box In PHP

Select all check box using one check box

  •          Here we are going to create a page that contains 6 check boxes. 

  •          And 2 other checkbox which we use for selects all and deselect all.

  •          Now open your favorite PHP text editor and type following code.

  •          Here I am going to create a webpage that contain 6 Language.


<p>Pls Select languages you know;</p>

<form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">



  print"<input type='checkbox' name='lang[]'  value='C'>C<br>";

  print"<input type='checkbox' name='lang[]'  value='c++'>C++<br>";

  print"<input type='checkbox' name='lang[]'  value='Java'>JAVA<br>";

  print"<input type='checkbox' name='lang[]'  value='V.B.NET'>V.B.NET<br>";

  print"<input type='checkbox' name='lang[]'  value='ASP.NET'>ASP.NET<br>";

  print"<input type='checkbox' name='lang[]'  value='c sharp'>C Sharp<br>" ;

  print"<input type=checkbox name='ckeckall' value='ckeckall' onclick='checkall(checkall)'>Select


  print"<input type=checkbox name='ckeckall1' value='ckeckall1'






  • Save this file as index.php.







·         Here our design Part has finished.



  •          Now we are going to add javascript for select all checkboxes using one check box .

  •           Add following code to index.php in between <head></head> head tag.




<script language="javascript">

function checkall(chkall)        //  Function for select all check box. 


       var chk=form1.elements; 

      for(var i=0;i<chk.length;i++)











  }                                                            // finished


  function uncheck(uc)  //Function for deselect all


            var chk1=form1.elements;

           for(var i=0;i<chk1.length;i++)










}      //finished                                                                                                                                              



  •    Now save this file. 

  •    Open your favorite browser and run this file.




·         Now here you can see when we click on select all check boxes all the check will select.

·         Now click on uncheck all, all the check box will unchecked.

·         Here our tutorial for select and deselect using checkbox now over have fun with PHP.