SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Image Array

  1. #1
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image Array

    Hello,

    I would highly apprecaite it if anyone one can help out with this one. I have 20 image and I would like to display them dynamically onto a web page.

    all images are 100 X 100.

    I have created an image array.

    Can I use a for loop and have all the iamges display side by side.

    Thanks

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    20 images

    If you mean 20 images like
    [][][][][][][][][][][][][][][][][][][][]
    I would think twice. Do you really want the page to have a row of images 2000 pxels wide (not counting padding, border, or margins!)? You could "write" them into a div and style in nowrap.
    I think it would be better to write() them into a div, but let them move. eg.
    [][][]
    [][][]
    [][][]
    [][][]
    [][][]
    [][][]
    [][]
    or
    [][][][][][][]
    [][][][][][][]
    [][][][][][]
    or
    [][][][][][][][][]
    [][][][][][][][][]
    [][]
    or
    [][][][][][][][][][][]
    [][][][][][][][][]
    etc.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Mittineague,

    Thank you for sharing your knowledge, I think you have misunderstood my thread. Each image is 100 pixel by 100 pixel. After I create an image array, I would like to have these images display on page side by side without having to script each one. I was wondering if FOR lOOP would serve the purpose?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    for loop

    You could use a javascript for loop. Either document.write or append to the DOM. something like:
    HTML Code:
    for(var i = 0; i < img_arr.length; i++){
    document.write("<img src='" + img[i] + "' />");
    }
    Of course if you want the height, width, and alt attributes too, you need a multi-dimensional array or multiple arrays.


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
  •