i'm trying to auto submit the value of drop down menu using onchange=this.form.submit() into database but i couldn't make it work. can anyone please help me. any suggestions will be highly appreciated.
here is the code:
<?
require_once ('database.php');
?>
<form action="" method=post>
<select name="assignee" onchange="this.form.submit()">
<option value="0">Unassigned</option>
<?
$find_selected = mysql_query("select assign_to from orders where id = $id");
$asignee =mysql_fetch_row($find_selected);
$list=mysql_query("SELECT id, full_name from user where username <> 'root' and nature = 3");
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['id']; ?>"<? if($row_list['id']== $asignee['0']){ echo "selected"; } ?>><? echo $row_list['full_name'] ?></option>
<?
}
mysql_free_result($list);
mysql_free_result($find_selected);
?>
</select>
</form>
<?php
if(isset($_POST['submit'])){
$sql = "UPDATE `orders` SET `assign_to` = '{$_POST['assignee']}' WHERE `id` = '$id' ";
mysql_query($sql) or die(mysql_error());
}
?>