function addRow(idTb,content1,content2,content3,content4,content5)
{
tabBody=document.getElementById(idTb);
row=document.createElement("TR");
cell1 = document.createElement("TD");
cell2 = document.createElement("TD");
cell3 = document.createElement("TD");
cell4 = document.createElement("TD");
cell5 = document.createElement("TD");
textnode1=document.createTextNode(content1);
textnode2=document.createTextNode(content2);
textnode3=document.createTextNode(content3);
textnode4=document.createTextNode(content4);
divNode5=document.createElement("div");
divNode5.innerHTML = content5;
cell1.appendChild(textnode1);
cell2.appendChild(textnode2);
cell3.appendChild(textnode3);
cell4.appendChild(textnode4);
cell5.appendChild(divNode5);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
row.appendChild(cell5);
tabBody.appendChild(row);
}
function cleanTableBody(idTb)
{
tabBody=document.getElementById(idTb);
while(tabBody.hasChildNodes())
{
tabBody.removeChild(tabBody.firstChild);
}
}
function caricaDediche(nomeFile,ordinamento) {
var ajax = assegnaXMLHttpRequest(),usaLink = true;
if(ajax) {
usaLink = false;
ajax.open("get", nomeFile+'?order='+ordinamento, true);
ajax.setRequestHeader("connection", "close");
ajax.onreadystatechange = function() {
if(ajax.readyState === readyState.COMPLETATO) {
if(statusText[ajax.status] === "OK"){
var objs= eval(ajax.responseText);
cleanTableBody('tbDedicheBody');
for(var i=0; i < objs.length; i ++){
obj = objs[i];
linkModifica = '<a href="/PyGuestbook/index.py/edit_dedica?id='+obj.id+'">Edit</a>  ';
linkElimina = '<a href="/PyGuestbook/index.py/elimina_dedica?id='+obj.id+'">Elimina</a>';
addRow('tbDedicheBody',obj.dataInserimento,obj.nickname,obj.email, obj.messaggio,linkModifica+linkElimina);
}
}else {
elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
}
}
}
ajax.send(null);
}
return usaLink;
}