spiritwithin
asked on
Array problem
Hi,
imagine this:
var fileArray = new Array();
function addFile(tableID, fileName, fileSize, dateString, dimX, dimY) {
if (fileArray.length) var currentIndex = fileArray.length;
else var currentIndex = 0;
fileArray[currentIndex] = new Object();
fileArray[currentIndex]["f ileName"] = fileName;
fileArray[currentIndex]["f ileSize"] = fileSize;
fileArray[currentIndex]["d ateString" ] = dateString;
fileArray[currentIndex]["d imX"] = dimX;
fileArray[currentIndex]["d imY"] = dimY;
clearFileList(tableID);
updateFileList(tableID);
dw_scrollObj.scrollTo(tabl eID+'_wn', 0,((fileAr ray.length -1)*150));
//print_r(fileArray,0);
}
Now, my actual problem is, that everytime i add such an Element to the array, i also do get an "undefined" element in the array. I tried to pop() it out but this pops out the one i added. I tried to use push(object) instead of the above code to add a new element, but also there i do get an "undefined" element.
Any ideas on this?
imagine this:
var fileArray = new Array();
function addFile(tableID, fileName, fileSize, dateString, dimX, dimY) {
if (fileArray.length) var currentIndex = fileArray.length;
else var currentIndex = 0;
fileArray[currentIndex] = new Object();
fileArray[currentIndex]["f
fileArray[currentIndex]["f
fileArray[currentIndex]["d
fileArray[currentIndex]["d
fileArray[currentIndex]["d
clearFileList(tableID);
updateFileList(tableID);
dw_scrollObj.scrollTo(tabl
//print_r(fileArray,0);
}
Now, my actual problem is, that everytime i add such an Element to the array, i also do get an "undefined" element in the array. I tried to pop() it out but this pops out the one i added. I tried to use push(object) instead of the above code to add a new element, but also there i do get an "undefined" element.
Any ideas on this?
Where do you see the "undefined" element ?
ASKER
I use some cheap print_r clone for javascript to inspect the array. That's where i see the undefined element. Besides that i pass the array to an image sorter tool which then shows up an image called "undefined".
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.