Hey, I am trying to get some information about an array I have created in JS. My code is: var passInfo = []; //ID3 passInfo['conv_Id3Title'] = document.getElementById('conv_Id3Title').value; passInfo['conv_Id3Album'] = document.getElementById('conv_Id3Album').value; alert(passInfo.length); Code (markup): When the alert pops up I get 0 displayed. Why is it saying that this array has no elements?
Ok, I've sorted that out as it appears the length method doesnt work for associative arrays. My next confusing issue is: var passInfo = []; passInfo['conv_Added'] = document.getElementById('conv_Added').value; passInfo['conv_From'] = document.getElementById('conv_From').value; finaldata = JSON.stringify(passInfo); alert(finaldata); Code (markup): I get an alert with "[]". Shouldn't this be returning the json string? and yes, the json object is definitely included in the page. var passInfo = []; passInfo[0] = document.getElementById('conv_Added').value; passInfo[1] = document.getElementById('conv_From').value; finaldata = JSON.stringify(passInfo); alert(finaldata); Code (markup): Works without any problems