473,796 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript arrays

2 New Member
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 994
rainclair
2 New Member
does anyone know how to make four arrays for the next and previous button?
Jan 21 '08 #2
gits
5,390 Recognized Expert Moderator Expert
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
4262
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) and puts values in a number of arrays and then puts the contents of the array in a HTML table. I'd like to keep the array structure. I've checked out all sorts of different javascript parsers but have not met with a great deal of success with any...
13
2533
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
4649
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 month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and hash is the base for it. I summarized all points in this article:...
35
6669
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
2012
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 text boxes and then I read the values using javascript objects.
104
17016
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 that array Could you show me a little example how to do this? Thanks.
41
4983
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 the hash are alphabetically sorted if the key happens to be alpha numeric. Which I believe makes sense because it allows for fast lookup of a key.
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.