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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advanced looping question 1

Status
Not open for further replies.

reisende

Programmer
Mar 16, 2004
74
US
Hi everyone.

I have a question about looping which I have been trying tp figure out for the last day or so and I want to see if any of you guys may have an idea.

What I am working on is a paged record set (like a search results page) that prints out links to each subsequent page like so:

Code:
<%
  for i = 1 to intPageCount
    if i = intPageCurrent then
      Response.Write(i)
    else
%>
<a href="category.asp?catId=<%= catId %>&page=<%= i %>"><%= i %></a>
<%
    end if
  next 'I
   
  if intPageCurrent < intPageCount then
%>
<a href="category.asp?catId=<%= catId %&page=<%= intPageCurrent + 1 %>">[&gt;&gt;]</a>
<%
  end if
%>

I would like to add a variable into the query strings of the links shown above which would increment by a set number for each page.

For example:

Link to Page 2: value = 4
Link to Page 3: value = 8
Link to Page 4: value = 12
and so on...

Basically it will increment the value by four for each page (intPageCount).

I'd like the links to then look like this when printed:

Code:
<a href="category.asp?catId=1&page=1&value=0">1</a>
<a href="category.asp?catId=1&page=2&value=4">2</a>
<a href="category.asp?catId=1&page=3&value=8">3</a>
<a href="category.asp?catId=1&page=4&value=12">4</a>

If anyone has any ideas, I'd love to hear them. Thanks.
 
Code:
<%
  [b]intValue = 0[/b]

  for i = 1 to intPageCount
    if i = intPageCurrent then
      Response.Write(i)
    else
%>
<a href="category.asp?catId=<%= catId %>&page=<%= i %>[b]&value=<%=intValue%>">[/b]<%= i %></a>
<%
    end if

    [b]intValue = intValue + 4[/b]
  next 'I

Tony
________________________________________________________________________________
 
Man, I shoulda known it was just a simple increment like that.

Thanks for quick reply, Tony. Now maybe I can keep on track without any more brain dumps :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top