Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset into Javascript...

Status
Not open for further replies.
May 9, 2000
446
GB
Hi I have a recordset in ASP that returns a load of data in rows. On another page i have a small piece of javascript that scrolls text vertically on the screen.

Anyway I was thinking that it'd be cool to have the javascript on the same page as the recordset and have it scroll through the list of records returned by the asp side of things (i'm using vbscript).... can anyone tell me how to achieve this / point me in the right direction?

Cheers
 
Hi ...
can you post your codes ( both javascript and asp part) here ?

TNX.
E.T.
 
Its pretty long but here goes....

The Javascript:

<script language=&quot;JavaScript1.2&quot;>
//change the scrollers width (in pixels)
var scrollerwidth=300
//change the scrollers height
var scrollerheight=30
//change the scrollers scroll speed (larger is faster)
var speed=1
//change the scrollers contents

var scrollercontents='<font face=&quot;Arial&quot; syle=&quot;normal&quot; color=&quot;#F4D09F&quot; size=&quot;-1&quot; ><div align=&quot;left&quot;>New Dates Listed...<p></p>New pictures up...<p></p>New news...<p></p></div></font>'

if (document.all)
document.write('<marquee direction=&quot;up&quot; scrollAmount='+speed+' style=&quot;width:'+scrollerwidth+';height:'+scrollerheight+'&quot;>'+scrollercontents+'</marquee>')

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout(&quot;window.onresize=regenerate&quot;,450)
intializescroller()
}
}

function intializescroller(){
document.vscroller01.document.vscroller02.document.write(scrollercontents)
document.vscroller01.document.vscroller02.document.close()
thelength=document.vscroller01.document.vscroller02.document.height
scrollit()
}

function scrollit(){
if (document.vscroller01.document.vscroller02.top>=thelength*(-1)){
document.vscroller01.document.vscroller02.top-=speed
setTimeout(&quot;scrollit()&quot;,100)
}
else{
document.vscroller01.document.vscroller02.top=scrollerheight
scrollit()
}
}

window.onload=regenerate2
</script>


And the ASP i'm using to display the records is....

<%If(Recordset1.Fields.Item(&quot;Date&quot;).Value) <>&quot;&quot; Then%>
</font></font></font></font></b></font><font color=&quot;#3CA3FF&quot;>Dates:</font><font color=&quot;#3CA3FF&quot; size=&quot;-2&quot;><font color=&quot;#F4D09F&quot;>
<%If (Recordset1.Fields.Item(&quot;Date&quot;).Value) = Date() Then%>
</font></font></i></font></b><font color=&quot;#F4D09F&quot; size=&quot;-2&quot;><i>Tonight!
-
<%Else%>
<%= DoDateTime((Recordset1.Fields.Item(&quot;Date&quot;).Value), 1, 1033) %> -
<%End If%>
<%=(Recordset1.Fields.Item(&quot;Where&quot;).Value)%></i></font></font> <font color=&quot;#F4D09F&quot; size=&quot;-2&quot;><i>
<%End If%>

Thats it!

Cheers

 
Hi There ...
OK ... here the code ...



'--------------------------------------------------------
<script language='JavaScript1.2'>
var scrollercontents ;

scrollercontents = '<font face=Arial syle=normal color=#F4D09F size=-1><div align=left>' ;

<%
Do While Not Recordset1.EOF
If(Recordset1.Fields.Item(&quot;Date&quot;).Value) <> &quot;&quot; Then
Response.Write &quot;scrollercontents = scrollercontents + '<font color=#3CA3FF>Dates:</font>' ;&quot; & vbCrLf
If (Recordset1.Fields.Item(&quot;Date&quot;).Value) = Date() Then
Response.Write &quot;scrollercontents = scrollercontents + '<font color=#F4D09F size=-2>Tonight! - </font>' ;&quot; & vbCrLf
Else
Response.Write &quot;scrollercontents = scrollercontents + '<font color=#F4D09F size=-2>&quot; & DoDateTime((Recordset1.Fields.Item(&quot;Date&quot;).Value), 1, 1033) & &quot; - </font>' ;&quot; & vbCrLf
End If
Response.Write &quot;scrollercontents = scrollercontents + '&quot; & Recordset1.Fields.Item(&quot;Where&quot;).Value & &quot;' ; &quot; & vbCrLf
Response.Write &quot;scrollercontents = scrollercontents + '<br><br>' ;&quot;
End If
Recordset1.MoveNext()
Loop
%>

scrollercontents = scrollercontents + '</div></font>' ;
</script>

'----------------------------------------------------------


<script language=&quot;JavaScript1.2&quot;>
//change the scrollers width (in pixels)
var scrollerwidth=300
//change the scrollers height
var scrollerheight=30
//change the scrollers scroll speed (larger is faster)
var speed=1
//change the scrollers contents


if (document.all)
document.write('<marquee direction=&quot;up&quot; scrollAmount='+speed+' style=&quot;width:'+scrollerwidth+';height:'+scrollerheight+'&quot;>'+scrollercontents+'</marquee>')

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout(&quot;window.onresize=regenerate&quot;,450)
intializescroller()
}
}

function intializescroller(){
document.vscroller01.document.vscroller02.document.write(scrollercontents)
document.vscroller01.document.vscroller02.document.close()
thelength=document.vscroller01.document.vscroller02.document.height
scrollit()
}

function scrollit(){
if (document.vscroller01.document.vscroller02.top>=thelength*(-1)){
document.vscroller01.document.vscroller02.top-=speed
setTimeout(&quot;scrollit()&quot;,100)
}
else{
document.vscroller01.document.vscroller02.top=scrollerheight
scrollit()
}
}

window.onload=regenerate2
</script>

TNX.
E.T.
 
Hi ehsant, cheers for the response but i can't get the code above to work..... you've divided the two scripts by a line do the scripts go in different parts of the opage (above header etc) I've tried that and putting it all into one script but can't get it to work! Sorry if i'm being thick!
 
Hi There ...
I just put those breaker to show you the part which I had worked on.
and it's better they be seperated.
and what is the error if it doesn't work ?

TNX.
E.T.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top