Scottwland
04-24-2003, 04:49 PM
I am trying to put a rotating text message on my website but I want the text to be pulled from a database. I get all of the records from the database on the error page but it does not rotate like it should. I have added the Javascript below.
If anyone could help I would appreciate it Thanks
Scott
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/xxx.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_xxx_STRING
Recordset1.Source = "SELECT product_name FROM products"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Repeat2__numRows = -1
Dim Repeat2__index
Repeat2__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat2__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>
<%
While ((Repeat2__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<%=(Recordset1.Fields.Item("product_name").Value)%>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
Recordset1.MoveNext()
Wend
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
</p>
<p>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var beforeMsg = "<center><font color=blue size=+2><b>";
var afterMsg = "</b></font></center>";
var msgRotateSpeed = 2000; // Rotate delay in milliseconds
var textStr = new Array();
textStr[0] = '<%=(Recordset1.Fields.Item("product_name").Value)%>';
textStr[1] = "2";
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
if (document.layers) {
document.write('<ilayer id="NS4message" height=25 width=100%><layer id="NS4message2" height=25 width=100%></layer></ilayer>')
temp = 'document.NS4message.document.NS4message2.document.write(beforeMsg + textStr[i++] + afterMsg);'+
'document.NS4message.document.NS4message2.document.close()';
}
else if (document.getElementById) {
document.write(beforeMsg + '<div id="message" style="position:relative;">IE division</div>' + afterMsg);
temp = 'document.getElementById("message").firstChild.nodeValue = textStr[i++];';
}
else if (document.all) {
document.write(beforeMsg + '<div id="message" style="position:relative;">IE division</div>' + afterMsg);
temp = 'message.innerHTML = textStr[i++];';
}
var i = 0;
function msgRotate() {
eval(temp);
if (i == textStr.length) i = 0;
setTimeout("msgRotate()", msgRotateSpeed);
}
window.onload = msgRotate;
// End -->
</script>
</p>
</body>
</html>
<%
Recordset1.Close()
%>
If anyone could help I would appreciate it Thanks
Scott
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/xxx.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_xxx_STRING
Recordset1.Source = "SELECT product_name FROM products"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Repeat2__numRows = -1
Dim Repeat2__index
Repeat2__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat2__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>
<%
While ((Repeat2__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<%=(Recordset1.Fields.Item("product_name").Value)%>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
Recordset1.MoveNext()
Wend
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
</p>
<p>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var beforeMsg = "<center><font color=blue size=+2><b>";
var afterMsg = "</b></font></center>";
var msgRotateSpeed = 2000; // Rotate delay in milliseconds
var textStr = new Array();
textStr[0] = '<%=(Recordset1.Fields.Item("product_name").Value)%>';
textStr[1] = "2";
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
if (document.layers) {
document.write('<ilayer id="NS4message" height=25 width=100%><layer id="NS4message2" height=25 width=100%></layer></ilayer>')
temp = 'document.NS4message.document.NS4message2.document.write(beforeMsg + textStr[i++] + afterMsg);'+
'document.NS4message.document.NS4message2.document.close()';
}
else if (document.getElementById) {
document.write(beforeMsg + '<div id="message" style="position:relative;">IE division</div>' + afterMsg);
temp = 'document.getElementById("message").firstChild.nodeValue = textStr[i++];';
}
else if (document.all) {
document.write(beforeMsg + '<div id="message" style="position:relative;">IE division</div>' + afterMsg);
temp = 'message.innerHTML = textStr[i++];';
}
var i = 0;
function msgRotate() {
eval(temp);
if (i == textStr.length) i = 0;
setTimeout("msgRotate()", msgRotateSpeed);
}
window.onload = msgRotate;
// End -->
</script>
</p>
</body>
</html>
<%
Recordset1.Close()
%>