By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

Image Object help displaying images

praclarush
P: 27
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.
Expand|Select|Wrap|Line Numbers
  1.     //declare image array
  2.     var product = new Array();
  3.     product[0] = new Image();
  4.     product[1] = new Image();
  5.     product[2] = new Image();
  6.     product[3] = new Image();
  7.     product[4] = new Image();
  8.     product[5] = new Image();
  9.     product[6] = new Image();
  10.     product[7] = new Image();
  11.     product[8] = new Image();
  12.     product[9] = new Image();
  13.     //populate image array
  14.     product[0].src = "images/colorpads.jpg";
  15.     product[1].src = "images/glue.jpg";
  16.     product[2].src = "images/highlighter.jpg";
  17.     product[3].src = "images/notecard.jpg";
  18.     product[4].src = "images/pad.jpg";
  19.     product[5].src = "images/pen.jpg";
  20.     product[7].src = "images/pencil.jpg";
  21.     product[8].src = "images/permmarkers.jpg";
  22.     product[9].src = "images/scissors.jpg";
  23.  
and here is the code that i tried to use
Expand|Select|Wrap|Line Numbers
  1. document.write("<td class='product_image'>");
  2. document.write("<img id='"+i+"'/>");
  3. document.images[i].src = product[i];
  4. document.write("</td>")
  5.  
i also tried it like this but it also didn't work
Expand|Select|Wrap|Line Numbers
  1. document.image("<img src="+product[i]+"/>"
  2.  
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
Nov 11 '07 #1
Share this Question
Share on Google+
2 Replies


Dasty
Expert 100+
P: 101
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.
Expand|Select|Wrap|Line Numbers
  1.     //declare image array
  2.     var product = new Array();
  3.     product[0] = new Image();
  4.     product[1] = new Image();
  5.     product[2] = new Image();
  6.     product[3] = new Image();
  7.     product[4] = new Image();
  8.     product[5] = new Image();
  9.     product[6] = new Image();
  10.     product[7] = new Image();
  11.     product[8] = new Image();
  12.     product[9] = new Image();
  13.     //populate image array
  14.     product[0].src = "images/colorpads.jpg";
  15.     product[1].src = "images/glue.jpg";
  16.     product[2].src = "images/highlighter.jpg";
  17.     product[3].src = "images/notecard.jpg";
  18.     product[4].src = "images/pad.jpg";
  19.     product[5].src = "images/pen.jpg";
  20.     product[7].src = "images/pencil.jpg";
  21.     product[8].src = "images/permmarkers.jpg";
  22.     product[9].src = "images/scissors.jpg";
  23.  
and here is the code that i tried to use
Expand|Select|Wrap|Line Numbers
  1. document.write("<td class='product_image'>");
  2. document.write("<img id='"+i+"'/>");
  3. document.images[i].src = product[i];
  4. document.write("</td>")
  5.  
i also tried it like this but it also didn't work
Expand|Select|Wrap|Line Numbers
  1. document.image("<img src="+product[i]+"/>"
  2.  
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 ...
Nov 11 '07 #2

praclarush
P: 27
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
Nov 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.