Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-16-2002, 11:49 AM   PM User | #1
pthompson2002
New Coder

 
Join Date: Aug 2002
Location: Ipswich
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
pthompson2002 is an unknown quantity at this point
taking data from a database and putting it into an array

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.
pthompson2002 is offline   Reply With Quote
Old 08-16-2002, 05:00 PM   PM User | #2
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
ok, this is JSCRIPT, which probaly isn't much help, but...


Code:
<@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>
Spudhead is offline   Reply With Quote
Old 08-16-2002, 08:14 PM   PM User | #3
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
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.
Roy Sinclair is offline   Reply With Quote
Old 08-19-2002, 12:53 AM   PM User | #4
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Roy's suggestion is a good way to go. I do that all the time!
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 08-19-2002, 08:49 AM   PM User | #5
pthompson2002
New Coder

 
Join Date: Aug 2002
Location: Ipswich
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
pthompson2002 is an unknown quantity at this point
cheers, that worked fine.

thanks for the help

Pete
pthompson2002 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:08 PM.


Advertisement
Log in to turn off these ads.