I have a a form:
<form id="deletesubmit" style="display:inline" >
<input style="width:50px" type="text" id="delcustomerid" name="delcustomerid" value="'.$row['customersid'].'">
<button type="submit" class="table-button ui-state-default ui-corner-all" title="delete"><span class="ui-icon ui-icon-trash"></span></button>
</form>
The form gets the customers id and inserts it as value. It shows the correct customer is for that row everything is fine. Then when i post the form via ajax somehow it posts the id of a diffent row. This is the script:
$("form#deletesubmit").submit(function() {
var delcustomerid = $('#delcustomerid').attr('value');
$.ajax({
type: "POST",
url: "delete/process.php",
data: "delcustomerid="+ delcustomerid,
success: refreshTable
});
return false;
});
});
And finally here is the php to post the form:
<?php include("../../config/config.php"); ?>
<?php
$deleteid = htmlspecialchars(trim($_POST['delcustomerid']));
mysql_send("DELETE FROM customers where id='$deleteid'");
?>
I have tested it without the ajax and it works fine. There must be something missing. It is not posting the correct value. Spent days trying to work it out.