Link to home
Start Free TrialLog in
Avatar of spiritwithin
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]["fileName"] = fileName;
            fileArray[currentIndex]["fileSize"] = fileSize;
            fileArray[currentIndex]["dateString"] = dateString;
            fileArray[currentIndex]["dimX"] = dimX;
            fileArray[currentIndex]["dimY"] = dimY;

            clearFileList(tableID);                  
            updateFileList(tableID);

            dw_scrollObj.scrollTo(tableID+'_wn',0,((fileArray.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?

Avatar of ozo
ozo
Flag of United States of America image

Where do you see the "undefined" element ?
Avatar of spiritwithin
spiritwithin

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
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial