Hi all i need some help with my ajax! I am trying to get a real time update of a table...
this is a table row for editing values in the database it is generated over and over in a for loop for each record there is.
Below also is my AJAX which searches a the database for records (which generates the table below)
but I cannot get it to work with the delete check box... when the check box is clicked i want the value to be sent and then the row deleted... any ideas?
Question
Original Poster
Hi all i need some help with my ajax! I am trying to get a real time update of a table...
this is a table row for editing values in the database it is generated over and over in a for loop for each record there is.
Below also is my AJAX which searches a the database for records (which generates the table below)
but I cannot get it to work with the delete check box... when the check box is clicked i want the value to be sent and then the row deleted... any ideas?
<script>
function searchBox() {
param = "sc="+document.getElementById("sc").value;
param = param+"&searchop="+document.getElementById("searchop").value;
param = param+"&submit=Search";
param = param+"&search="+document.getElementById("searchy").value;
run(param);
}
function deleteBox(delVar) {
param = "del=del";
param = param+"&delete="+delVar;
param = param+"&submit=edit";
param = param+"&search="+document.getElementById("searchy").value;
run(param);
}
function run(param) {
var xmlhttp;
document.getElementById("cars").innerHTML = "Loading.."+document.getElementById("cars").innerHTML;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("cars").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST", "add.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(param);
}
</script>
[/CODE]
Link to comment
Share on other sites
7 answers to this question
Recommended Posts