samedi 18 avril 2015

using AJAX function in added row

I have this function to fetch information from a database with AJAX



function CLO() {
var a=document.getElementById("keyword").value;
var b=document.getElementById("chapter").value;
if (a == ""&& b == "") {
document.getElementById("CLO").innerHTML = "";

return;
} else {
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("CLO").innerHTML = xmlhttp.responseText;

}
}

xmlhttp.open("GET","PLO.php?q1="+escape(a)+"&q2="+escape(b),true);
xmlhttp.send();
}
}


and this function to addrow onclick button



function addRow(tableID){
var table=document.getElementById(tableID);
var rowCount=table.rows.length;
var row=table.insertRow(rowCount);
var colCount=table.rows[0].cells.length;
var cell1=row.insertCell(0);
cell1.innerHTML= rowCount+1;
for(var i=0;i<colCount;i++){
var newcell=row.insertCell(i+1);
newcell.innerHTML=table.rows[0].cells[i+1].innerHTML;
}}


I'm trying to use the CLO() function in added row and send the respond to it but I couldn't. I need you recommendation and help in how to accomplish that Thank you


Aucun commentaire:

Enregistrer un commentaire