|
|
|
อยากให้เวลาเรากดลบ แล้วมีการยืนยันก่อนที่จะลบ โดยเขียนแบบ AJAX อ่ะครับ |
|
|
|
|
|
|
|
ทำได้แล้ว
หน้าแรก codeย่อๆ
//**********
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript">
function confirmDel(){
question = confirm("Are you sure you want to delete this record?")
if (question =="0"){
top.location = url
}
}
</script>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Mode,ID) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'drug-delete.php';
var pmeters = "tMode=" + Mode +
"&w=" + document.getElementById("ward").value +
"&d=" + document.getElementById("tdate").value +
"&tID=" + ID;//ส่งตัวแปรไปอีก2ตัว เพื่อเป็นเงื่อนไขในการ query ข้อมูลมาแสดง
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
</HEAD>
<body Onload="JavaScript:doCallAjax('LIST','');">
<span id="mySpan"></span>
</BODY>
</HTML>
/*****************************
หน้า 2 Code ย่อๆ
<a href="#" Onclick="confirmDel(); return false,doCallAjax('DELETE','<?=$fd[0];?>');">Delete</a>
|
ประวัติการแก้ไข 2011-02-09 09:31:27 2011-02-09 09:32:05
|
|
|
|
Date :
2011-02-08 16:43:30 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|