tags:

views:

21

answers:

2

I need to list images from the server. The problem is that, first image needs to be in different div. I dont know what I do wrong here. The following code lists images as;

1.jpg

1.jpg 2.jpg 3.jpg

but it needs to list as;

1.jpg

2.jpg 3.jpg

           <div id="main"> 
                <a href="<%=IMAGES(0)%>" title="<%=objProduct("PRODUCTNAME")%>"><img src="<%=IMAGES(0)%>" alt="<%=objProduct("PRODUCTNAME")%>" id="productimage" /></a>        

<%
    i = 0
    For Each IMAGE In IMAGES 
    i = i + 1
%>
                <a href="<%=IMAGE%>" title="<%=objProduct("PRODUCTNAME")%>"></a>        
<%
    Next
%>
            </div>
A: 
<%
    i = 0
    For Each IMAGE In IMAGES 
    i = i + 1
    if (i > 1) then
%>
                <a href="<%=IMAGE%>" title="<%=objProduct("PRODUCTNAME")%>"></a>        
<%
    end if
    Next
%>
Jason
A: 

The point is that first you correctly create the first div. But then you use for each loop, and it will always iterate over all images. Thus doing the first image twice. You can solve this in many different ways, one would be to use While loop for image 2 - n, another would be to have an if statement checking if it is the first image.

bjorsig