JavaScript Array Funny

Soldato
Joined
18 Oct 2002
Posts
16,030
Location
The land of milk & beans
I'm trying to understand exactly what's going on here, but can't get my head around it...

Code:
	var arrAddresses = new Array()
			
	arrAddresses[0,0] = '23 Any Lane'
	arrAddresses[0,1] = 'Any Town'
	arrAddresses[0,2] = 'Anywhere'
	arrAddresses[0,3] = ''
	arrAddresses[0,4] = ''
	arrAddresses[0,5] = 'AN1 3ER'
	arrAddresses[0,6] = 'GB'
	arrAddresses[0,7] = '0207 878787'
	
	arrAddresses[1,0] = '25 Some Street'
	arrAddresses[1,1] = 'Some Town'
	arrAddresses[1,2] = 'Somewhere'
	arrAddresses[1,3] = ''
	arrAddresses[1,4] = ''
	arrAddresses[1,5] = 'SO4 3WH'
	arrAddresses[1,6] = 'GB'
	arrAddresses[1,7] = '0208 272727'
	
	arrAddresses[2,0] = 'Lorem Ipsum'
	arrAddresses[2,1] = 'Dolor sit'
	arrAddresses[2,2] = 'Amet consectetuer'
	arrAddresses[2,3] = 'Adipiscing'
	arrAddresses[2,4] = 'Elit'
	arrAddresses[2,5] = 'AB12 3CD'
	arrAddresses[2,6] = 'GB'
	arrAddresses[2,7] = '01234 567890'
	
	function setAddress(szSelectedAddress) {				
		alert(szSelectedAddress)
		
		alert(arrAddresses[szSelectedAddress,1])
	}
Now, no matter what I change the first index of the array to - even if it's hard coded to 1,1 - it always comes back with the last element's details (thats all the Latin stuff).

Anyone know why? I have a feeling it's a numpty mistake, but I've been staring at it so long I can't see it :o
 
Back
Top Bottom