pthompson2002
08-16-2002, 11:49 AM
I have a table called "Broadcast" and would like to take the contents of the "Title" column and put it into an array. This array will then be displayed in a javascript scroll bar which I already have working.
My problem is I don't know how to get the data from the database into the Array using ASP.
Can anyone help?
thanks Pete
P.S the javascript just uses a straightforward array at the moment to display the messages.
Spudhead
08-16-2002, 05:00 PM
ok, this is JSCRIPT, which probaly isn't much help, but...
<@LANGUAGE=JSCRIPT%>
<%
//get a recordset populated. I assume you have one already
%>
<html>
<head>
<script language="JavaScript">
var myArray=new Array();
<%
var counter=0
while (!myRecordSet.EOF){
%>
myArray[counter]="<%=rs.Fields("myColumnName")%>";
<%
counter++
rs.MoveNext;
}
%>
</script>
</head>
<body>
<script language="JavaScript">
for(i=0;i<myArray.length;i++){
document.write(myArray[i]);
}
</script>
</body></html>
Roy Sinclair
08-16-2002, 08:14 PM
At the appropriate place where you define the javascript array loop through the recordset and have it response.write the values to fill the array. Think of it as having the server side ASP code writing the client side javascript code.
whammy
08-19-2002, 12:53 AM
Roy's suggestion is a good way to go. I do that all the time!
pthompson2002
08-19-2002, 08:49 AM
cheers, that worked fine.
thanks for the help
Pete