If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

This is meant to be a code snippet in which the images inside the "images" variable are displayed in a list (to control which image is being displayed on a slideshow)

The problem lies with the fact that I have never used "create node" DOM before and therefore don't know whats wrong here. I have a feeling its that the loop is trying to put the new image nodes in the same place (not 1 then another then another like a list). The problem with this line of thought, however, is that I then don't know how to do this in another way if I am correct.

Any and all help with be great.

Thanks all

ps: dumb question, how do you edit a post on this site? I can't for the life of me find the big "edit" button.

There is one major and one minor issue with your code. The minor issue is that the push call to imageholders is completely pointless as you will override that element in the next line anyway. The major issue is your loop condition:

Code:

for(var i=0;i==images.length;i++)

It should probably be

Code:

for(var i=0;i<images.length;i++)

This will at least display the pictures. As for the slideshow you're talking about I'm not sure what exactly it is you want. Currently it will just display all images in the images array.

P.S.: I think you can't edit a post unless you have a certain number of posts.

Perfect!

Originally Posted by Airblader

There is one major and one minor issue with your code. The minor issue is that the push call to imageholders is completely pointless as you will override that element in the next line anyway. The major issue is your loop condition:

Code:

for(var i=0;i==images.length;i++)

It should probably be

Code:

for(var i=0;i<images.length;i++)

This will at least display the pictures. As for the slideshow you're talking about I'm not sure what exactly it is you want. Currently it will just display all images in the images array.

P.S.: I think you can't edit a post unless you have a certain number of posts.

Works brilliantly now that I implemented your two fixes.

Minor error: Yet another dumb moment when I thought I had to create the variable before I could assign in a value.

Major error: Still not even sure why that didn't work. I thought the For loops second part was the condition at which it ends the loop (ie a given point or a greater or lesser then point). O well anyway, gap in my knowledge filled in.

The slideshow i mentioned is already working with another code which I didn't post. Sorry if this confused you :S

I thought the For loops second part was the condition at which it ends the loop

You thought wrong! You better read up on it here and make sure to understand the difference, because it is crucial.

But FYI, even if it were true, 'i == images.length' would still be wrong. Your array has a length of 4, which means the indices range goes from 0 to 3. If i were to be 4, you would run out of bounds. Granted, in Javascript it will only return 'undefined', in other languages your program will die with an error.