Image Reference

  • Thread starter Thread starter Carl Gilbert
  • Start date Start date
C

Carl Gilbert

Hi

I have a page and at the top of which I am defining some images as follows:

<%
img_1 = "images\image1.gif"
img_2 = "images\image2.gif"
%>

and so on but with more complex filenames.

Further on in the code, I want to reference this image in an <IMG> tag.
Usually I would go src=<%=img_1%>, but in this case I am using a loop, e.g.
<%For x=1 To 7%>

Is there anyway to combine the number of the loop with "img_" to give me
something like "img_1", "img_2" and so on depending on the position in the
loop.

I can join the two so it looks for an image with that name but I need use
this string to reference the image defined at the top of the page.

Regards, Carl Gilbert
 
Carl,
Are you using ASP or ASP.Net? If you are doing ASP, you can do something
like:


<%
img = "images/img_{ID}.gif"
%>

<% for x = 1 to 7 %>
<img src="<%=Replace(img, "{ID}", x)%>">
<% next %>

If you are doing this in ASP.Net, you are way off on how you should be
programming.

Karl
 
Back
Top