By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,953 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

javascript arrays

P: 2
Hello,

I am trying to get 4 sets of thumbnails (each set in a hidden div tag) to onClick show in a main picture box. The links to the hidden divs are just below the main picture box. I can get everything to work, but my problem is when the next and previous are clicked ALL pictures are shown.
What I would like is when the first set of thumbnails comes up, the big picture will only scroll through the first set of large pictures...etc...

I dont know if this makes since to anyone...??? I think I need 4 sets if arrays but not sure how to code the javascript for the arrays that coincide with the next and previous....

here is the code I have so far in an external javascript file...


Expand|Select|Wrap|Line Numbers
  1.  var num=0
  2.   img0 = new Image ()
  3.   img0.src = "1.gif"
  4.   img1 = new Image ()
  5.   img1.src = "2.gif"
  6.   img2 = new Image ()
  7.   img2.src = "3.gif"
  8.   img3 = new Image ()
  9.   img3.src = "4.gif"
  10.   img4 = new Image ()
  11.   img4.src = "5.gif"
  12.   img5 = new Image ()
  13.   img5.src = "6.gif"
  14.   img6 = new Image ()
  15.   img6.src = "7.gif"
  16.   img7 = new Image ()
  17.   img7.src = "8.gif"
  18.   img8 = new Image ()
  19.   img8.src = "9.gif"
  20.   img9 = new Image ()
  21.   img9.src = "10.gif"
  22.  
  23. function next()
  24.   {
  25.    num=num+1
  26.    if (num==10)
  27.     {num=0}
  28.  document.mypic.src=eval("img"+num+".src")
  29.    }
  30.  
  31. function prev()
  32.   {
  33.    num=num-1
  34.    if (num==10)
  35.     {num=0}
  36.  document.mypic.src=eval("img"+num+".src")
  37.    }
  38. //put thumb into large window
  39.  
  40.  function canManipulateImages() {
  41.     if (document.images)
  42.         return true;
  43.     else
  44.         return false;
  45. }
  46. function loadmypic(imageURL) {
  47.     if (gImageCapableBrowser) {
  48.         document.mypic.src = imageURL;
  49.         return false;
  50.     }
  51.     else {
  52.         return true;
  53.     }
  54. }
  55. gImageCapableBrowser = canManipulateImages();
  56.  
  57. function canManipulateImages() {
  58.     if (document.images)
  59.         return true;
  60.     else
  61.         return false;
  62. }
  63. function loadthumbsad(imageURL) {
  64.     if (gImageCapableBrowser) {
  65.         document.thumbsad.src = imageURL;
  66.         return false;
  67.     }
  68.     else {
  69.         return true;
  70.     }
  71. }
  72. gImageCapableBrowser = canManipulateImages();
Jan 21 '08 #1
Share this Question
Share on Google+
2 Replies


P: 2
does anyone know how to make four arrays for the next and previous button?
Jan 21 '08 #2

gits
Expert Mod 5K+
P: 5,327
hi ...

first you don't need the eval ... simply remove it since it is useless and pure overhead ;) ... you never need to use eval ... besides the eval of json-responses from an ajax-call ...

second: what do you mean with your 'sets' ... could you explain a bit more? may be an example would help ...

kind regards
Jan 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.