vendredi 21 août 2015

My check all checkboxes not working

I have this form that gets data from the database and displays checkboxes.I have a function to check and uncheck all boxes but its not working.can anyone please help?

      <form id="myform" method="POST" action="PHPMailer/examples/mail-exec.php">
   <div class="row">
  My Trailers :</br>
  <div class="form-group" style="overflow-y: auto; height:100px;">
  <input type="checkbox" name="Check_ctr" value="yes"     onClick="Check(document.myform.check_list)"><b>Check Control</b> </br>
   <?php 
   $qry="SELECT * from followers where vendorid =$vendorid";
  $stmt = $conn->prepare( $qry );
  $stmt->execute();
  while($row = $stmt->fetch(PDO::FETCH_ASSOC))
 {?>
 <input type="checkbox" name="check_list" value="<?php echo      $row['email'];?>"><?php echo $row['name'];?><br>
 <?php } ?>     
 </div>                         
 </form>

here is the js function:

                <SCRIPT LANGUAGE="JavaScript">
                <!--

                <!-- Begin
                function Check(chk)
                {
                if(document.myform.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>




Aucun commentaire:

Enregistrer un commentaire