Results 1 to 1 of 1

Thread: Check box problem

  1. #1
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Check box problem

    Hi ,

    I have a problem with check box. can any body help me.
    here if i select the class the sections are selecting but when i submit i need to display class and sections separate. i am able to display classes but when i want to display sections i am facing the problem. plz help me on this.....

    Below is my code.....


    Code:
    <?php
    mysql_pconnect("localhost","root","");
    mysql_select_db("zftutorial");
    if($_POST['submit']){
    extract($_POST);
    	echo "<pre>";
    	echo "<BR>";
    	print_r($class);
    }
    ?>
    <script type="text/javascript">
    function checkall(idv,ids)
    { //alert(idv);
     var a=new Array();
     a=document.getElementsByName(ids);
     for(var i=0;i<a.length; i++){ //alert("hi");
      a[i].checked=document.getElementById(idv).checked;
     }
    }
    </script>
    <form action="" method="post" name="frm">
    <table cellpadding="0" cellspacing="5" border="0">
    <?php
    $sql=mysql_query("select * from m_classes order by class_id");
    while($row=mysql_fetch_array($sql)){
    ?>
    <tr><td><strong><input type="checkbox" id="<?php echo $row['class_name'];?>" name="class[]" onclick="checkall('<?php echo $row['class_name'];?>','<?php echo $row['class_name'];?>[]')" value="<?php echo $row['class_id'];?>"/><?php echo $row['class_name'];?></strong>
     <table>
     <?php
      $sql2=mysql_query("select * from  m_classes_sections where class_id='".$row['class_id']."'");
      while($row2=mysql_fetch_array($sql2)){
      ?>
     <tr><td><input type="checkbox" name="<?php echo $row['class_name'];?>[]" value="<?php echo $row['class_id'].','.$row2['section_id'];?>"/><?php echo $row2['section_name'];?></td></tr>
     <?php } ?>
     
     </table>
    </td></tr>
    <?php }?>
    <tr><td><input type="submit" name="submit" value="submit" /></td></tr>
    </table>
    </form>
    Last edited by jscheuer1; 08-04-2010 at 10:33 AM. Reason: format code

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •