Update value dynamically using Select OnChange
HTML part
<select name="notice_status" id="notice_status" onChange="UpdateStatus(<?=$row->id?>,this.value)">
<option value="Yes" <?=($row->status=='Yes')?'selected':'';?>>Yes</option>
<option value="No" <?=($row->status=='No')?'selected':'';?>>No</option>
</select>
JQuery
<script type="text/javascript">
function UpdateStatus(id,status)
{
$.ajax({
type: "POST",
url: "update-status.php",
data: {
status: status,
id: id
},
success: function(msg){
if(msg == 'OK')
{
alert('Status updated successfully');
}
else
{
alert(msg);
}
}
});
}
</script>
The update-status.php file
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if ($post)
{
$Query = "UPDATE table SET Status = '".$_POST['status']."' WHERE id = ".$_POST['id'];
$result = ExecuteQuery($Query);
if($result> 0 )
{
echo 'OK';
}
else
{
return mysql_error();
}
}