View Full Version : Array objects
02-24-2003, 08:20 PM
I have a page with a mix of images that I don't want indexed. It is a 5x5 grid, each being an image (but the border edges are counted too unfortunately.). So I assign names to the images instead. That is a very space consuming thing to do. So now I try to put all the names into an array to reduce recurring names throughout the file like this:
N=document.images.M.src //(assume some values)
When I try to set variables form arrays, I get many errors like "object expected" and "undefined". Is there a way to fix this?
02-24-2003, 08:36 PM
Ok, "document.images.M.src" is invalid. My question for you is, what is 'M'? You you have images named M0, M1, M2, M3, etc?
02-24-2003, 09:27 PM
Lets say I have
M=Array("A1","A2","A3","A4","A5","B1") // all the way up to E5
N=Array() //blank array for adding on to
Then I have images in a grid each with a name.
<img src="2p0.gif" name="A1" />
and I want to dynamically change the images at certain events in a shifting way.
I could write 25 lines of that. But I wanted to simplify it into a for loop.
for (i=0; i<25; i++)
document.images.M[i].src=N[i+1] //building a new array
It's the M part that is being taken literal.
02-24-2003, 09:50 PM
Oh, you need
02-24-2003, 10:37 PM
Ah :) I knew it had to be something simple like that. Thanks!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.