How to autosave when i select item in dropdown list with different dropdown value for each rows

How to autosave when i select item in dropdown list with different dropdown value for each rows

sum458sum458 Posts: 2Questions: 1Answers: 0

index.php

$(document).ready(function(){ $('select.status').on('change',function () { var decision = $(this).val(); var id = $('td.myid').html(); alert(decision); alert(id); $.ajax({ type: "POST", url: "saveDecision.php", data: {decision: decision, id: id }, success: function(msg) { $('#autosavenotify').text(msg); } }) }); });

Ajax autosave

1 --Select-- Approve Reject Pending

SaveDecision.php
<?php
if (isset($_POST['id'])) {
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$decision=$_POST['decision'];
$id=$_POST['id'];
$query = "UPDATE decision SET select_result='$decision' WHERE id=$id";
$resource = mysql_query($query)
or die (mysql_error());
echo 'decision table is successfully updated to '.$decision;
}

<?php > ----------------------------------------------------------------- MySQL Database CREATE TABLE IF NOT EXISTS `decision` ( `id` int(8) NOT NULL, `select_result` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `decision` (`id`, `select_result`) VALUES (1, ' '); INSERT INTO `decision` (`id`, `select_result`) VALUES (2, ' '); INSERT INTO `decision` (`id`, `select_result`) VALUES (3, ' '); INSERT INTO `decision` (`id`, `select_result`) VALUES (4, ' '); ___________________________________________________________ the above code updates the 1st row only How to update or autosave the 2nd, 3rd, 4th, ... etc rows in a datatables ?>

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @sum458 ,

    Is this the same issue as this thread?

    There's a lot of code going on. I'm not seeing any reference to Editor so assume you're updating yourself. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.