I’m having trouble with some simple syntax: I have a repeated operation that I want to change to a simple for loop e.g.
document.images.photoslider0.src=photos[0]
document.images.photoslider1.src=photos[1]
document.images.photoslider2.src=photos[2]
document.images.photoslider3.src=photos[3]
document.images.photoslider4.src=photos[4]
where photos[] is an array of image names and
photoslider(x) is the name of the image objects on my page. – I want to change this to something like:
function doImages(){
for (var x=4; x<0; x–){
document.images.photoslider(x).src=photos[x]
}
But this doesn’t work because the syntax for photoslider(x) is not correct. So far I’ve tried:
document.images.(photoslider + x).src=photos[x]
document.images[(photoslider+x)].src=photos[x]
document.images.[photoslider+x].src=photos[x]
document.images[eval(photoslider+x)].src=photos[x]
document.images.photoslider[x].src=photos[x]
and many others, none of which work. Does anyone know the correct syntax for this simple operation?:mad: