Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

How to create a counter?

Posted 05 Feb 2004 15:37:50
1
has voted
05 Feb 2004 15:37:50 James Lee posted:
Hi Everyone,

I have used Repeat Region Server Behaviour in Dreamweaver to loop a certain set of record. Is there a way to create a counter for the repeat region so that I will have a number beside a certain set of record? Inside Dreamweaver, there is a server behaviour where it can find the first and last set of records but that is not enough. I know a way is to add another field inside the table and let it auto-number it. But inside ASP, is it possible to create a counter inside the repeat region loop and print out the number beside each record? I wonder..

Thanks for reading!

Replies

Replied 06 Feb 2004 13:59:40
06 Feb 2004 13:59:40 Lee Diggins replied:
Hi Peggy

Outside of the repeat region, dim a variable call it Counter and set the value to 1. Inside the repeat region you'll need something to response.write the Counter and an increment the value of Counter by one each time you loop through the repeat region, something like this:

Dim Counter
Counter = 1

While (Not rsMyRecordset.EOF)
Response.Write(Counter)
'the rest of your data/code here
Counter = Counter + 1
Wend

If you're still unsure, post your repeat region code and I'll take a look

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 07 Feb 2004 05:52:34
07 Feb 2004 05:52:34 James Lee replied:
Thanks for your quick response. I will try it!


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Peggy

Outside of the repeat region, dim a variable call it Counter and set the value to 1. Inside the repeat region you'll need something to response.write the Counter and an increment the value of Counter by one each time you loop through the repeat region, something like this:

Dim Counter
Counter = 1

While (Not rsMyRecordset.EOF)
Response.Write(Counter)
'the rest of your data/code here
Counter = Counter + 1
Wend

If you're still unsure, post your repeat region code and I'll take a look

Digga

Sharing Knowledge Saves Valuable Time!!!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 10 Feb 2004 02:21:01
10 Feb 2004 02:21:01 Phil Shevlin replied:
You really don't have to create a new variable. MM already has one in the repeat region behavior. I think its Repeat1__index

Try it or one of the other ones near it. Just print it in the row to test it.

Reply to this topic