Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Show Next and Previous in JS Array

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36476
    Arkitekt
    Participant

    Hi –

    I have a simple JS that i am using to show a picture gallery. Simply click on the thumbnail, and the larger version of the image is shown in the designated area. It is working excatly how I wanted it to up till this point.

    I have decided that I want to add previous and next arrows, but have not been able to get them to work. The pictures are in an array with the larger versions of the images named; 1.jpg, 2.jpg, 3.jpg, etc… and the thumbnail versions corresponding with t1.jpg, t2.jpg, t3.jpg, etc…

    What JS and html do i need to get this working?

    Java

    // set variables
    var count = 0
    var portImages = new Array()

    // define images in array
    var i = 1
    while (i <= imgCount) {
    portImages = i+".jpg"
    i++
    }

    // preload portfolio images
    var preloadedimages=new Array()
    for (i=1;i<=imgCount;i++){
    preloadedimages
    =new Image()
    preloadedimages
    .src=portImages
    }

    // function for viewing previous image
    function showImage(whichImage) {
    document.getElementById('large_image').src = portImages[whichImage]
    }

    html
















    thumbnail thumbnail thumbnail thumbnail thumbnail thumbnail thumbnail thumbnail thumbnail thumbnail




    «Prev
    Next »

    Any help would be appreciated.

    #138587
    Piotr
    Member

    Hello,
    I have similar idea: I’ve found this:

    where “slide’ is a class name of images, and first image has {display: block} , and other have {display:none;} .
    Buttons are like this:

    It works pretty well, except IE – so I think it has a tiny defect, which I cannot find: I am not a programmer. My gallery is very simple, with thumbs as well.

    I will by grateful for any help to make it working in IE.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.