I have combined the repeat region behavior with a random record extension. I then placed this in an auto vertical scroll box. The result is that I get a constant scrolling of random pictures displayed from my database. The only problem is that whenever the random select chooses the last record, this line from the repeat region shuts down the loop:
While ((Repeat1__numRows <> 0) AND (NOT rsads.EOF))
I tried removing the " AND (NOT rsads.EOF)) " but this creates an endless loop which locks up my server and the page won't load. Can anyone help me figure out a way to make the scrolling constant without making the loop lock things up? Below is the code within the scroll box. Thanks for any help.
<div id="AutoScrollContainer">
<!-- Do NOT define (additional) styles for the following nested layer here.
If required, modify the styles in the head section -->
<div id="AutoScrollContent">
<table width='200' cellpadding='2' border='0' cellspacing='0'>
<tr>
<td><%
While ((Repeat1__numRows <> 0) AND (NOT rsads.EOF))
%>
<p>
<%
' Moving to random record - Steven Jones' Extension
If Not(rsads.bof and rsads.eof) Then
' reset the cursor to the beginning
If (rsads.CursorType > 0) Then
rsads.MoveFirst
Else
rsads.Requery
End If
rsads_totalrn = -1
rsads_totalrn = rsads.RecordCount ' ony works on some recordsets, but much faster
If (rsads_totalrn = -1) Then ' and if it didn't work, we still have to count the records.
' count the total records by iterating through the recordset
rsads_totalrn=0
While (Not rsads.EOF)
rsads_totalrn = rsads_totalrn + 1
rsads.MoveNext
Wend
' reset the cursor to the beginning
If (rsads.CursorType > 0) Then
rsads.MoveFirst
Else
rsads.Requery
End If
End If
' now do final adjustments, and move to the random record
rsads_totalrn = rsads_totalrn - 1
If rsads_totalrn > 0 Then
Randomize
rsads.Move Int((rsads_totalrn + 1) * Rnd)
End If
End If
' all done; you should always check for an empty recordset before displaying data
%>
<%
If rsads.Fields.Item("adimage
1").Value <> "" Then
If rsads.Fields.Item("adtitle
").Value = "" Then
If rsads.Fields.Item("adbody"
).Value = "" Then
%>
<a href="<%=(rsads.Fields.Ite
m("adlink"
).Value)%>
" onMouseOver="flvXAS1(0)" onMouseOut="flvXAS1(1,1,50
,1)"><img src="<%=(rsads.Fields.Item
("adimage1
").Value)%
>" width="<%=(rsads.Fields.It
em("adsize
h").Value)
%>" height="<%=(rsads.Fields.I
tem("adsiz
ev").Value
)%>" border="0" /></a></p>
<%
End If
End If
End If
%>
<%
Repeat1__index=Repeat1__in
dex+1
Repeat1__numRows=Repeat1__
numRows-1
rsads.MoveNext()
Wend
%>
<p><a href="javascript:;" onMouseOver="flvXAS1(0)" onMouseOut="flvXAS1(1,1,50
,1)">hyper
links</a> in the AutoScroller, eg. for links to news items.</p></td>
</tr>
</table>
</div>
</div>
<!-- End absolute positioned Cross-browser AutoScroller -->
Start Free Trial