PDA

View Full Version : Problem with variable transfer...



BillyBoB6969
03-14-2009, 06:26 AM
I am trying to make an image (the edit img) appear when the user logs in. It has a function for the onmousedown event that should transfer the variable from ajax xmlresponse to the img attribute pID.



function editBlog(EntryID, SecurityCode) {
alert(EntryID);
}

function makeEditable(userID) {
if(sendReq2.readyState == 4 || sendReq2.readyState == 0) {
sendReq2.open("POST",'includes/getPosts.php?userID='+userID+'&secCode='+secCode, true);
sendReq2.onreadystatechange = function() {
if(sendReq2.readyState == 4) {
var xmlDoc = sendReq2.responseXML.documentElement;
var i = 0;
var items = xmlDoc.getElementsByTagName("entry");
var o = [];
var iEdit = [];
var iRemove = [];
while(i<items.length) {
iEdit[i] = document.createElement("img");
iEdit[i].pID = items[i].attributes[0].textContent;
iEdit[i].src = "images/EditBtn.jpg";
iEdit[i].alt = "Edit";
iEdit[i].onmousedown = function() {
editBlog(this.pID, secCode);
}
iRemove[i] = document.createElement("img");
iRemove[i].src = "images/RemoveBtn.jpg";
iRemove[i].alt = "Remove";
var posID = items[i].firstChild.textContent;
o[i] = document.getElementById('BlogO'+posID);
clearObj(o[i]);
o[i].appendChild(iEdit[i]);
o[i].appendChild(document.createTextNode(" "));
o[i].appendChild(iRemove[i]);
i++;
}
}
}
sendReq2.send(null);
}
}


It just outcomes undefined... The url to the site is: The Site (http://dreamshowstudios.net/development/Blog/index.php).

I reloaded the page and got it to work. Thanks for looking anyways.