javascript arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rainclair
    New Member
    • Jan 2008
    • 2

    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...


    [CODE=javascript] var num=0
    img0 = new Image ()
    img0.src = "1.gif"
    img1 = new Image ()
    img1.src = "2.gif"
    img2 = new Image ()
    img2.src = "3.gif"
    img3 = new Image ()
    img3.src = "4.gif"
    img4 = new Image ()
    img4.src = "5.gif"
    img5 = new Image ()
    img5.src = "6.gif"
    img6 = new Image ()
    img6.src = "7.gif"
    img7 = new Image ()
    img7.src = "8.gif"
    img8 = new Image ()
    img8.src = "9.gif"
    img9 = new Image ()
    img9.src = "10.gif"

    function next()
    {
    num=num+1
    if (num==10)
    {num=0}
    document.mypic. src=eval("img"+ num+".src")
    }

    function prev()
    {
    num=num-1
    if (num==10)
    {num=0}
    document.mypic. src=eval("img"+ num+".src")
    }
    //put thumb into large window

    function canManipulateIm ages() {
    if (document.image s)
    return true;
    else
    return false;
    }
    function loadmypic(image URL) {
    if (gImageCapableB rowser) {
    document.mypic. src = imageURL;
    return false;
    }
    else {
    return true;
    }
    }
    gImageCapableBr owser = canManipulateIm ages();

    function canManipulateIm ages() {
    if (document.image s)
    return true;
    else
    return false;
    }
    function loadthumbsad(im ageURL) {
    if (gImageCapableB rowser) {
    document.thumbs ad.src = imageURL;
    return false;
    }
    else {
    return true;
    }
    }
    gImageCapableBr owser = canManipulateIm ages();[/CODE]
    Last edited by gits; Jan 21 '08, 10:43 PM. Reason: added code tags
  • rainclair
    New Member
    • Jan 2008
    • 2

    #2
    does anyone know how to make four arrays for the next and previous button?

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      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

      Comment

      Working...