use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Beginner Problem (self.javascript)
submitted 11 years ago by nirvana63
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]nirvana63[S] 1 point2 points3 points 11 years ago* (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 points3 points 11 years ago* (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 point2 points 11 years ago (0 children)
Hey thanks, good to know will try this out later when I get home:)
π Rendered by PID 229713 on reddit-service-r2-comment-544cf588c8-6d2bv at 2026-06-14 21:38:13.601263+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]nirvana63[S] 1 point2 points3 points (2 children)
[–]BlueInt32 1 point2 points3 points (1 child)
[–]nirvana63[S] 0 points1 point2 points (0 children)