Any ideas please:
I have a page which displays a list of products from the database. For each product I also want to display an image. The images are all named based on the ProductID from the database - ie 1.gif, 2.gif etc.
However, for some product IDs , there is no image. In this case, I want to display a standard "No picture available" GIF. Is there a way in HTML to have alternate image if one isn't found? At the moment, I'm using ASP to see if the image exists, and if not setting the img source in ASP to the alternate image, but I'm a bit concerned about performance. Current code shown at end...
Thanks, Tamsin
[sig][/sig]
I have a page which displays a list of products from the database. For each product I also want to display an image. The images are all named based on the ProductID from the database - ie 1.gif, 2.gif etc.
However, for some product IDs , there is no image. In this case, I want to display a standard "No picture available" GIF. Is there a way in HTML to have alternate image if one isn't found? At the moment, I'm using ASP to see if the image exists, and if not setting the img source in ASP to the alternate image, but I'm a bit concerned about performance. Current code shown at end...
Thanks, Tamsin
Code:
<% var fso = new ActiveXObject("Scripting.FileSystemObject");
var filespec = "../products/" + rstProduct.Fields.Item("ProdID").Value + ".gif";
if (fso.FileExists(Server.MapPath(filespec))) { %>
<img src="../products/<%=(rstProduct.Fields.Item("ProdID").Value)%>.gif">
<% } else { %>
<img src="../images/NoPic.gif">
<% } %>
[sig][/sig]