Forums
This topic is locked
How to Loop a asp page?
Posted 18 Mar 2002 11:28:26
1
has voted
18 Mar 2002 11:28:26 Henrik Sandeberg posted:
I have an ACCESS db and a index.asp page that consists of a recordset, I want to repeat the records on the page after some time, etc 5 sec, but i will only show 1 record on the page at the same time. And when the last record is shown i will have the first record in the db shown again. A loop something....Can anyone help,?
Henrik
Replies
Replied 18 Mar 2002 14:47:49
18 Mar 2002 14:47:49 Andrew Watson replied:
You can try something along these lines...
The display page should have the recordset on it filtered by a variable (entered value).
This variable should be incremented every time the page is refreshed. then youre returned record will step through the recordset.
to set the incremental try something like this..
(Set this variable to 0 or 1 before this page or use the session on start or something)
<ASP%
varMyIncremental = varMyIncremental + 1
%ASP>
the recordset should have a key column of an incrementing number this is then filtered with the variable above and each time the page is refreshed the next record is displayed.
Use a simple refresh action in the header content to refresh after X seconds.
Oh, once the recordset gets to the end it will stop so you should state somewhere that if EOF is true then go back to the beginning of the recordset.
The display page should have the recordset on it filtered by a variable (entered value).
This variable should be incremented every time the page is refreshed. then youre returned record will step through the recordset.
to set the incremental try something like this..
(Set this variable to 0 or 1 before this page or use the session on start or something)
<ASP%
varMyIncremental = varMyIncremental + 1
%ASP>
the recordset should have a key column of an incrementing number this is then filtered with the variable above and each time the page is refreshed the next record is displayed.
Use a simple refresh action in the header content to refresh after X seconds.
Oh, once the recordset gets to the end it will stop so you should state somewhere that if EOF is true then go back to the beginning of the recordset.
Replied 19 Mar 2002 11:59:46
19 Mar 2002 11:59:46 Henrik Sandeberg replied:
ok, thanks, i will try this, i had something like this in mind but i couldnt do it. I post the page,, meybe you can help me with the code....
code:
<pre id=code><font face=courier size=2 id=code><%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/iTV.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "JA"
if (Request("MM_EmptyValue" <> "" then Recordset1__MMColParam = Request("MM_EmptyValue"
%>
<%
Dim TidAttVisa
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_iTV_STRING
Recordset1.Source = "SELECT * FROM pres WHERE visa = '" + Replace(Recordset1__MMColParam, "'", "''" + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../include/amf1.css" type="text/css">
<style type="text/css">
<!--
.kursivliten { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-style: italic; color: #666666}
.headerstor { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-style: normal; font-weight: bold; text-decoration: underline}
-->
</style>
<meta http-equiv="refresh" content="<%=(Recordset1.Fields.Item("visastid".Value)%>">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="800" border="0" cellspacing="0" cellpadding="1">
<tr>
<td colspan="3">
<div align="center" class="headerstor"><%=(Recordset1.Fields.Item("overskrift".Value)%></div>
</td>
</tr>
<tr>
<td width="26"> </td>
<td width="597"> </td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597">
<div align="left"></div>
<img src="<%=(Recordset1.Fields.Item("bildlank".Value)%>" border="0"></td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="norm12"><%=(Recordset1.Fields.Item("ingress".Value)%></td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="kursivliten"> </td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="kursivliten"><%=(Recordset1.Fields.Item("autodatum".Value)%></td>
<td width="171"><span class="kursivliten">Inlagt av:</span> <span class="kursivliten"><%=(Recordset1.Fields.Item("inlagtav".Value)%></span></td>
</tr>
</table>
</body>
</html>
<%
Recordset1.Close()
%>
</font id=code></pre id=code>
code:
<pre id=code><font face=courier size=2 id=code><%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/iTV.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "JA"
if (Request("MM_EmptyValue" <> "" then Recordset1__MMColParam = Request("MM_EmptyValue"
%>
<%
Dim TidAttVisa
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_iTV_STRING
Recordset1.Source = "SELECT * FROM pres WHERE visa = '" + Replace(Recordset1__MMColParam, "'", "''" + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../include/amf1.css" type="text/css">
<style type="text/css">
<!--
.kursivliten { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-style: italic; color: #666666}
.headerstor { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-style: normal; font-weight: bold; text-decoration: underline}
-->
</style>
<meta http-equiv="refresh" content="<%=(Recordset1.Fields.Item("visastid".Value)%>">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="800" border="0" cellspacing="0" cellpadding="1">
<tr>
<td colspan="3">
<div align="center" class="headerstor"><%=(Recordset1.Fields.Item("overskrift".Value)%></div>
</td>
</tr>
<tr>
<td width="26"> </td>
<td width="597"> </td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597">
<div align="left"></div>
<img src="<%=(Recordset1.Fields.Item("bildlank".Value)%>" border="0"></td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="norm12"><%=(Recordset1.Fields.Item("ingress".Value)%></td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="kursivliten"> </td>
<td width="171"> </td>
</tr>
<tr>
<td width="26"> </td>
<td width="597" class="kursivliten"><%=(Recordset1.Fields.Item("autodatum".Value)%></td>
<td width="171"><span class="kursivliten">Inlagt av:</span> <span class="kursivliten"><%=(Recordset1.Fields.Item("inlagtav".Value)%></span></td>
</tr>
</table>
</body>
</html>
<%
Recordset1.Close()
%>
</font id=code></pre id=code>