开发者

problem with listing images (listing first one twice)

开发者 https://www.devze.com 2022-12-17 12:19 出处:网络
I nee开发者_如何转开发d 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;

I nee开发者_如何转开发d 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>


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消