Creating new variables
I have the following code which I need some help with.
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)
var images = [
"", /* PICTURE 0 */
"", /* PICTURE 1 */
"", /* PICTURE 2 */
"", /* PICTURE 3 */
var holding = document.getElementById("chooseframe");
var imageholders = ;
imageholders[i] = document.createElement("IMG");
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.
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:
It should probably be
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.
Originally Posted by Airblader
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
You thought wrong! You better read up on it here and make sure to understand the difference, because it is crucial.
I thought the For loops second part was the condition at which it ends the loop
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)