Hi all,
i had a page with a dropdown option.so wen i select an item from dropdown my page is getting refresh and in the dropdown it is cuming to default value.I need that selected value in dropdown even after the page refreshed.so can any one please...
<?php
include 'connection.php';
$sql="SELECT projectname from projects where createdby='Jack'";
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='Jack' and role='2'";
mysql_error();
$result2=mysql_query($sql2);
$num=mysql_num_rows($result2);
$projectassign=$_POST['projectassign'];
?>
<script type="text/javascript" language="javascript">
function getValue(selval)
{
location.href="noname1.php?projassign="+selval;
}
</script>
<html>
<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;
?>