Image Object help displaying images

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praclarush
    New Member
    • Oct 2007
    • 27

    Image Object help displaying images

    I need to take an image that was in a Array object image and have it display in a table. this is for a item list the table has four columns one for the image, one for a description, one for a price, and the last for the amount of the item.
    I've looked on the internet for help but all I find is how to do image switches for links and slideshows. nothing on how to just pull the image from the array and then print it.
    this is the image array Im using, all it will display is the broken image icon.
    Code:
    	//declare image array
    	var product = new Array();
    	product[0] = new Image();
    	product[1] = new Image();
    	product[2] = new Image();
    	product[3] = new Image();
    	product[4] = new Image();
    	product[5] = new Image();
    	product[6] = new Image();
    	product[7] = new Image();
    	product[8] = new Image();
    	product[9] = new Image();
    	//populate image array
    	product[0].src = "images/colorpads.jpg";
    	product[1].src = "images/glue.jpg";
    	product[2].src = "images/highlighter.jpg";
    	product[3].src = "images/notecard.jpg";
    	product[4].src = "images/pad.jpg";
    	product[5].src = "images/pen.jpg";
    	product[7].src = "images/pencil.jpg";
    	product[8].src = "images/permmarkers.jpg";
    	product[9].src = "images/scissors.jpg";
    and here is the code that i tried to use
    Code:
    document.write("<td class='product_image'>");
    document.write("<img id='"+i+"'/>");
    document.images[i].src = product[i];
    document.write("</td>")
    i also tried it like this but it also didn't work
    Code:
    document.image("<img src="+product[i]+"/>"
    html wise its just a script in the body that calls a function to performs this and some other items that I already have working

    Any help would be nice,
    praclarush
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    Originally posted by praclarush
    I need to take an image that was in a Array object image and have it display in a table. this is for a item list the table has four columns one for the image, one for a description, one for a price, and the last for the amount of the item.
    I've looked on the internet for help but all I find is how to do image switches for links and slideshows. nothing on how to just pull the image from the array and then print it.
    this is the image array Im using, all it will display is the broken image icon.
    Code:
    	//declare image array
    	var product = new Array();
    	product[0] = new Image();
    	product[1] = new Image();
    	product[2] = new Image();
    	product[3] = new Image();
    	product[4] = new Image();
    	product[5] = new Image();
    	product[6] = new Image();
    	product[7] = new Image();
    	product[8] = new Image();
    	product[9] = new Image();
    	//populate image array
    	product[0].src = "images/colorpads.jpg";
    	product[1].src = "images/glue.jpg";
    	product[2].src = "images/highlighter.jpg";
    	product[3].src = "images/notecard.jpg";
    	product[4].src = "images/pad.jpg";
    	product[5].src = "images/pen.jpg";
    	product[7].src = "images/pencil.jpg";
    	product[8].src = "images/permmarkers.jpg";
    	product[9].src = "images/scissors.jpg";
    and here is the code that i tried to use
    Code:
    document.write("<td class='product_image'>");
    document.write("<img id='"+i+"'/>");
    document.images[i].src = product[i];
    document.write("</td>")
    i also tried it like this but it also didn't work
    Code:
    document.image("<img src="+product[i]+"/>"
    html wise its just a script in the body that calls a function to performs this and some other items that I already have working

    Any help would be nice,
    praclarush
    The first thing that cought my eye was:

    - you are creating array elements as image objects and store their paths into their "src" propery, but then (in the cycle) you are assigning path to new objects this way:

    [PHP]document.images[i].src = product[i];
    [/PHP]
    shouldnt it be:
    [PHP]document.images[i].src = product[i].src;
    [/PHP]

    if it wont help, let us know ...

    Comment

    • praclarush
      New Member
      • Oct 2007
      • 27

      #3
      Originally posted by Dasty
      The first thing that cought my eye was:

      - you are creating array elements as image objects and store their paths into their "src" propery, but then (in the cycle) you are assigning path to new objects this way:

      [PHP]document.images[i].src = product[i];
      [/PHP]
      shouldnt it be:
      [PHP]document.images[i].src = product[i].src;
      [/PHP]

      if it wont help, let us know ...
      hey thinks I can't belive i missed something so simple
      thinks a lot for the help,
      praclarush

      Comment

      Working...