hi all,
i had a page with a dropdown of projects and a table of users with check boxes each. so wen i select a project from dropdown the users who are assigned to that project will be checked and the rest as unchecked.
so here is my problem wen i select the project from dropdown the page gets reload and the value in the drop down cuming to the default value(---select project---).
I need the value as it is in the drop down.so can any one please...
here is my code.

<?php
include 'connection.php';
    $sql="SELECT projectname from projects where createdby='kishore'";
    mysql_error();
    $result=mysql_query($sql);
    $options=""; 
    while ($row=mysql_fetch_array($result)) 
    {
        $id=$row["projectid"];
        $projectname=$row["projectname"];
        $options.="<option value='".$projectname."'>".$projectname.'</option>';
    }  
    
    $sql2="SELECT * FROM users where reportingto='kishore' and role='2'";
    mysql_error();
    $result2=mysql_query($sql2);
    $num=mysql_num_rows($result2);
    $projectassign=$_POST['projectassign'];  
?>
<html>   
<head>
<script type="text/javascript" language="javascript"> 
 
function getValue(selval)
           {
                location.href="noname1.php?projassign="+selval;
           }   
</script>
</head>
<body>
<form name="myform">
<select id="prolist" name="projectassign" onchange="getValue(this.value);" >
<option >----select project----</option>
<?php echo $options ?> 
   
 </select> 
 
 <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
    <tr>
        <th></th>
        <th style="color: navy;">Userid</th>
        <th style="color: navy;">Username</th>
    </tr>
    <?php
    $sno=1;
    while($row=mysql_fetch_array($result2, MYSQL_ASSOC)){
    ?>
     <tr>
<td><input name="check_list" type="checkbox" value="<? echo $row['userid']; ?>"></td>
<td><? echo $row['userid']; ?></td>
<td><? echo $row['username'];?></td>
</tr>

<?php
    $sno=$sno+1;
}
?>
    </table>
</form>
</body>
</html>
              
          <?php
          $projval=$_GET['projassign'];
          $sql3="select userid from projectassign where projectassign='$projval'";
           mysql_error();
           $result3=mysql_query($sql3);
           $num1=mysql_num_rows($result3);
            $arruid=mysql_fetch_array($result3);
             $i=0;
             while ($i < $num1)
             {
                 $f1=mysql_result($result3,$i,"userid"); 
              //   echo $f1;
         
              echo "<script type='text/javascript' language='javascript'>
                var qval=". $f1 ." ;
                var chkarr=document.myform.check_list;
                for(i=0;i<chkarr.length;i++)
                {
                    
                    if(chkarr[i].value==".$f1.")chkarr[i].checked=true;
                }
                
              </script>";
              $i++; 
              }
            if($projval!='')  
            {
             echo "assigned users for ".$projval;
            }
            
           
        ?>

Due to that line 26. my page is getting refresh. if i remove that my checkbox wil not be checked on change. so is there any solution for this or can we do it in another way... please can any one help me..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.