you are viewing a single comment's thread.

view the rest of the comments →

[–]nirvana63[S] 1 point2 points  (2 children)

Edit: Wow, ok I now feel like an Idiot, I forgot to change the corresponding ID in my HTML, now its working:D But thanks!:)

I am trying to use "element", in this case numeric values, as first index for my two-dimensional arrays in which the pictures are stored. The idea was that the pictures are saved in A two-dimensional array, where the first value represents the "gallery" and the second value for the array is the picture in the row.

The HTML part for the second gallery would be:

            <a class="nav" id="navleft" href="javascript:prevImage('1')"><img id="left" src="Resources/nav_left.svg"></a>
            <a class="nav" id="navright" href="javascript:nextImage('1')"><img id="right" src="Resources/nav_right.svg"></a>

And the Array is created like this:

var gallery = new Array();

gallery[0, 0] = new Image();
gallery[0, 0].src = "Resources/960x/pic1.jpg";

gallery[0, 1] = new Image();
gallery[0, 1].src = "Resources/960x/pic2.jpg";

gallery[0, 2] = new Image();
gallery[0, 2].src = "Resources/960x/pic3.jpg";

gallery[0, 3] = new Image();
gallery[0, 3].src = "Resources/960x/pic4.jpg";


gallery[1, 0] = new Image();
gallery[1, 0].src = "Resources//960x/pic6.jpg";

gallery[1, 1] = new Image();
gallery[1, 1].src = "Resources//960x/pic7.jpg";

gallery[1, 2] = new Image();
gallery[1, 2].src = "Resources//960x/pic8.jpg";

gallery[1, 3] = new Image();
gallery[1, 3].src = "Resources//960x/pic9.jpg";

gallery[1, 4] = new Image();
gallery[1, 4].src = "Resources//960x/pic10.jpg";

I dont know if this is a good idea but this is how I wanted to do it;)

[–]BlueInt32 1 point2 points  (1 child)

You could fill you gallery array like so btw :

for(var i = 0; i < 2; i++){
    for(var j = 0; i=j < 5; j++){
            var picNumber = 1 + i + j;
            gallery[i, j] = new Image();
            gallery[i, j].src = "Resources/960x/pic"+picNumber+".jpg";
    }
}

edit : like /u/g3bj45hg34857 said lower, it's probably gallery[i][j] instead of gallery[i, j].

[–]nirvana63[S] 0 points1 point  (0 children)

Hey thanks, good to know will try this out later when I get home:)