
nugraha_isnan - 2011-12-04 18:43:25 -
In reply to message 1 from Douglas
create function with parameter... better do with ajax..
ElementID= the html element ID that would take ajax effect
ID= your primary key or the fieldname of your delete condition
handlePage= PHP code that would do the delete code
function deldata(handlePage,ElementID,ID) {
if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) {
var obj = document.getElementById(ElementID);
var form = obj.innerHTML;
obj.innerHTML = 'Deleting Data, please wait..';
xmlhttp.open('POST', handlePage, true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText + '<br>' + form;
setTimeout(tblReset(), 1000);
} else {
alert('Error : ' + xmlhttp.statusText);
}
}
}
var param = 'ID=' + ID;
xmlhttp.send(param);
}
}
and this is how to call your ajax function
$x->addStandardControl(EyeDataGrid::STDCTRL_DELETE,
"deldata('yourhandlePage.php','yourElementID','%yourprimarykey%')");
to make it easier i'll give you the handlepage example
<?php
$id = $_POST['ID'];
$query = "delete from table where yourID='" . $id . "'";
$result= mysql_query($query);
if ($result)
{
echo 'data has been deleted';
} else
{
echo '<font color="red">Error, CAN NOT DELETE DATA</font>';
}
?>
ajax is easy... cheersssss.........