Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create New Row after 3rd with this Horizontal Repeat 1

Status
Not open for further replies.

JordanR

Technical User
Oct 3, 2002
182
US
Hello, I am using the following code that allows for 6 out of 100 or some images to show on the page. All six images show on the same row. I want to divide the row and show only 3 images per row but keeping the six images per page can some one help me?
btw I am using the Recordset paging.
Code:
limit = 6
  <tr>
<%
         'Response.Write objRS.Fields("FILENAME").Value & "<br>" I can replace this with a table or whatever I need to loop through


   ' Display the records
    For t = 1 To limit

 %>
    <td><a href="details.asp?cat=<%=catalog%>&pid=<%=objRS("productID")%>"><img src="catalog/<%=objRS("product_imagefolder")%>/thumb-<%=objRS("product_number")%>.jpg" alt="<%=objRS("product_number")%>" border="0"><br><div align="center"><%=objRS("product_name")%></div></a></td>
  <%objRS.movenext%>
  <%if objRS.EOF then exit for%>
 <%

		  objRS.MoveNext
    Next
   
%>
  </tr>
 
Jumbled code...staggard look...

Looks like your using a database. I would seriously think about using pagination to do what you are talking about. More onto the point of your questions try this:

Code:
<table>
<% for i = 1 to 3
if objRS.eof = True then
   exit for
end if
%>
    <tr>
           <td><a href="details.asp?cat=<%=catalog%>&pid=<%=objRS("productID")%>"><img src="catalog/<%=objRS("product_imagefolder")%>/thumb-<%=objRS("product_number")%>.jpg" alt="<%=objRS("product_number")%>" border="0"><br><div align="center"><%=objRS("product_name")%></div></a></td>
<%
objRS.Movenext
if objRS.eof = True then
   exit for
end if
%>
    <td><a href="details.asp?cat=<%=catalog%>&pid=<%=objRS("productID")%>"><img src="catalog/<%=objRS("product_imagefolder")%>/thumb-<%=objRS("product_number")%>.jpg" alt="<%=objRS("product_number")%>" border="0"><br><div align="center"><%=objRS("product_name")%></div></a></td>
<%
objRS.Movenext
if objRS.eof = True then
   exit for
end if
%>   
    <td><a href="details.asp?cat=<%=catalog%>&pid=<%=objRS("productID")%>"><img src="catalog/<%=objRS("product_imagefolder")%>/thumb-<%=objRS("product_number")%>.jpg" alt="<%=objRS("product_number")%>" border="0"><br><div align="center"><%=objRS("product_name")%></div></a></td>
</tr>
<%
objRS.Movenext

next
%>
</table>

Please error check it because I have no way to check it. This should give you the 3x3 grid you wanted.
 
CassidyHunt,
Thanks that work.
What is pagination? Is that the same as the Recordset paging?

Thanks for your help.
 
Yeah Pagination is Recordset Paging. It just makes it easier to navigate the recordset and provide navigation. If you need an example let me know

Cassidy
 
Umm, rather than repeat the code three times, why not just use that counter to output end of ro and beginning of row tags?
Code:
limit = 6
     <%
     'Response.Write objRS.Fields("FILENAME").Value & "<br>" I can replace this with a table or whatever I need to loop through

   ' Display the records
   For t = 1 To limit
      [highlight]If i mod 3 = 1 Then Response.Write "<tr>"[/highlight]
      %>
      <td><a href="details.asp?cat=<%=catalog%>&pid=<%=objRS("productID")%>"><img src="catalog/<%=objRS("product_imagefolder")%>/thumb-<%=objRS("product_number")%>.jpg" alt="<%=objRS("product_number")%>" border="0"><br><div align="center"><%=objRS("product_name")%></div></a></td>
      <%
      objRS.movenext
      if objRS.EOF then exit for
      [highlight]If i mod 3 = 0 The Response.Write "</tr>"[/highlight]

      [highlight red]'objRS.MoveNext  <-- This is unnecessary you already movenext'd once[/highlight]
    Next
   
%>
  </tr>

you also had an extra MoveNext in there that I think was unnecessary. basically now what will happn is the tr tags will get added dynamically based on the value of the i counter. on 1, 4 ,7 etc it wil start a row and on 3, 6, 9 etc it would end the row.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Agreed Tarwn,

That is much more efficient and a better solution. I really didn't think about it that as much in Vbscript as I did in HTML aspect.

Thanks

Cassidy
 
Thank you both for the help.
Both way provided what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top