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>


<script type="text/javascript">
function UpdateStatus(id,status)
type: "POST",
url: "update-status.php",
data: {
status: status,
id: id
success: function(msg){
if(msg == 'OK')
alert('Status updated successfully');

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';
return mysql_error();

Get Free Email Updates!

Signup now and receive free offers, discounts & coupon codes

I agree to have my personal information transfered to Mad Mimi ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.