SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face how to pick a spot in array through a link

    I have a JavaScript array image gallery, each image in the array has a .src and a caption value, my question is, is there a way for me to have a thumbnail intro page with all the images and each thumbnail link would load the gallery.html page with its corresponding spot in the array?
    some way to pass code in the url itself?

    sorry if this doesn’t sound clear.

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    In order for that to work feasibly it would be best if gallery.html was done in php. Otherwise it gets too complicated. Another option you have is to use Lightbox to do what you're saying on the same page.

  3. #3
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what a great tip! thanks

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, just to clarify for anyone that does have a gallery.php file or uses a server side language:

    HTML Code:
    <img src="file.jpg" alt="Vacation in Italy" width="100" height="100" onclick="expand(this)"/>
    Code:
    function expand(image_element) {
      location.replace("gallery.php?alt=" + image_element.getAttribute("alt") + "&src=" + image_element.getAttribute("src"));
    }
    though do note that by having a php file accepting what could be user input, you will need to sanitize your data (things like absolute paths to images along with basename can help with that).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •