473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

javascript arrays

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
2 979
does anyone know how to make four arrays for the next and previous button?
Jan 21 '08 #2
gits
5,390 Expert Mod 4TB
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

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

Similar topics

4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
13
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
1
by: Alfredo Magallón Arbizu | last post by:
Hello, I need to pass the contents of a dataset to the client in order to use these contents with javascript. What is the best way to achieve that? Normally I use controls like a grid or...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.