Link to home
Create AccountLog in
Avatar of dlmcgown
dlmcgown

asked on

Nested Repeat Region and Horizontal looper

I am using classic ASP and Dreamweaver CS5. My database is SQL server. VB Script

I have implemented a nested repeat region. My outer repeat column is 'divisions'. The nested repeat is working well. Now, I want to make the records that populate under the divisions to repeat horizontally. I need to add a horizontal looper and I do not know how to do that within a nested repeat region.

Here is my code

<h1>Leader Board</h1>
          <%
While ((Repeat1__numRows <> 0) AND (NOT rsArcheryYouth.EOF))
%>
            <% TFM_nest = rsArcheryYouth.Fields.Item("division").Value
If lastTFM_nest <> TFM_nest Then
      lastTFM_nest = TFM_nest %>
            <h2><%=(rsArcheryYouth.Fields.Item("division").Value)%></h2>
            <%End If 'End Basic-UltraDev Simulated Nested Repeat %>
            <p><%=(rsArcheryYouth.Fields.Item("area").Value)%> | <%=(rsArcheryYouth.Fields.Item("score").Value)%></p>
            <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsArcheryYouth.MoveNext()
Wend
%>

What I need to be horizontal is:
 <p><%=(rsArcheryYouth.Fields.Item("area").Value)%> | <%=(rsArcheryYouth.Fields.Item("score").Value)%></p>

Thank you.
Avatar of jawa29
jawa29
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi

When viewed in a web browser you need it to look like this?

AreaA | 1 AreaB | 2 AreaC | 3

Is that right?

Jawa29
Avatar of dlmcgown
dlmcgown

ASKER

Yes sir

Division A

Area 1 | Area 2 | Area 3 | Area 4

I would like it to show four horizontal records under each division
Hi

I've taken a look and made some modifications to the script above that I think will output what you want, it will need testing as it's hard to totally cover everything without knowing DB structure etc...
<h1>Leader Board</h1>
<% 
sTxt = ""
While ((Repeat1__numRows <> 0) AND (NOT rsArcheryYouth.EOF)) 

	TFM_nest = rsArcheryYouth.Fields.Item("division").Value
	If lastTFM_nest <> TFM_nest Then 
		lastTFM_nest = TFM_nest
%>
<h2><%=(rsArcheryYouth.Fields.Item("division").Value)%></h2>
<%
	End If 'End Basic-UltraDev Simulated Nested Repeat
	If sTxt <> "" Then
		sTxt = sTxt & " | "
	End If
	sTxt = sTxt & rsArcheryYouth.Fields.Item("area").Value & " " & rsArcheryYouth.Fields.Item("score").Value
 
	Repeat1__index = Repeat1__index +1
	Repeat1__numRows = Repeat1__numRows -1
	rsArcheryYouth.MoveNext()
Wend
%>
<p><%= sTxt %></p>

Open in new window

Basically this will page through the records and add the results to a string (sTxt) once all records have been processed it will output to screen the value of sTxt.

Jawa29
Hi Jawa29, the output from your code did this:

Division 1
Division 2
Division 3
Division 4
Division 5
Area 1 | Area 2 | Area 3 | Area 4 | Area 5...

I need it to be:

Division A

Area 1 | Area 2 | Area 3 | Area 4
Division B
Area 1 | Area 2 | Area 3
Division C
Area 1 | Area 2 | Area 3
etc.

see http://www.brenhamkofc.org/bigbuck/leaders3.asp (testing page)

Thank you
Right sorry I see what's happened there :)

try:
<h1>Leader Board</h1>
<% 

While ((Repeat1__numRows <> 0) AND (NOT rsArcheryYouth.EOF)) 
	sTxt = ""
	TFM_nest = rsArcheryYouth.Fields.Item("division").Value
	If lastTFM_nest <> TFM_nest Then 
		lastTFM_nest = TFM_nest
%>
<h2><%=(rsArcheryYouth.Fields.Item("division").Value)%></h2>
<%
	End If 'End Basic-UltraDev Simulated Nested Repeat
	If sTxt <> "" Then
		sTxt = sTxt & " | "
	End If
	sTxt = sTxt & rsArcheryYouth.Fields.Item("area").Value & " " & rsArcheryYouth.Fields.Item("score").Value
 	Response.Write("<p>" & sTxt & "</p>")
	
	Repeat1__index = Repeat1__index +1
	Repeat1__numRows = Repeat1__numRows -1
	rsArcheryYouth.MoveNext()
Wend
%>

Open in new window

Jawa29
We are back to what I originally had...

see http://www.brenhamkofc.org/bigbuck/leaders3.asp (testing page)

The divisions and records are populating correctly. See Youth Archery division. The records repeat vertical. I need them to go horizontal and only populate 4 columns.

Thank you

My mistake, just refreshed your test page...

Move line 17 to go under line 21

Jawa29
Forget what I just said...... I'll be back
Hi I'm back, the issue with this particular output is that fact the text sits inside <p></p>

So test this one for me
<h1>Leader Board</h1>
<% 
sTxt = ""
While ((Repeat1__numRows <> 0) AND (NOT rsArcheryYouth.EOF))
	TFM_nest = rsArcheryYouth.Fields.Item("division").Value
	If lastTFM_nest <> TFM_nest Then
		If sTxt <> "" Then
			Response.Write(sTxt & "</p>")
			sTxt = ""
		End If
		lastTFM_nest = TFM_nest
		sHeadTxt = "<h2>" & rsArcheryYouth.Fields.Item("division").Value & "</h2>"
		sTxt = "<p>" & rsArcheryYouth.Fields.Item("area").Value & " " & rsArcheryYouth.Fields.Item("score").Value
	Else
		sTxt = sTxt & rsArcheryYouth.Fields.Item("area").Value & " " & rsArcheryYouth.Fields.Item("score").Value
	End If 'End Basic-UltraDev Simulated Nested Repeat
	
	Repeat1__index = Repeat1__index +1
	Repeat1__numRows = Repeat1__numRows -1
	rsArcheryYouth.MoveNext()
Wend
Response.Write(sTxt & "</p>")
%>

Open in new window

Jawa29
We are getting closer... Divisions are missing

http://www.brenhamkofc.org/bigbuck/leaders3.asp 
SOLUTION
Avatar of jawa29
jawa29
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
The Genius nailed it. I now have what I need. Jawa 29 stayed with me and I received a quick solution.
Excellent, glad I could help. See you in the Community some time :)
Jawa29, now, since we nailed the horizontal loop, I am told by client they now want

photo
firstName lastName
area | score

Division 1
photo <br />
firstName lastName <br />
area | score

Is this now too complicated? sorry.
No not complicated.

I'll work on the code for you and post back, it might be tomorrow.... is that ok?

Jawa29
Jawa29... I will make a re post for more points. I need to add some more to what you accomplished. Forget last comment.
Great!

yes that is ok (tomorrow)... thank you... I will upload a graphic of what the end result will look like
Jawa29... we are good. I am closing this out. Thank you for your support and care. There is no more work to be done with this looper. Again, thank you. Disregard the extra work. Thank you.