Questo semplice script consente di mostrare a video, tramite l'aiuto di un codice Javascript, dei dati estrapolati con una query SQL da un database.
L'utilizzo potrà essere quello di mostrare delle news in tempo reale ogni volta che viene ricaricata la pagina.
<%
Set Conn =Server.CreateObject("ADODB.Connection")
Conn.Open strConn
strSQL = "SELECT * FROM news ORDER BY data "
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open strSQL, Conn
do while not RS.EOF
strtesto = strtesto & "<b>" & RS("data") &"</b> " & _
RS("testo") & " "
RS.MoveNext
loop
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
<table align="center">
<tr>
<td width="16">News: </td>
<td>
<script language="JavaScript1.2">
var marqueewidth=504
var marqueeheight=10
var speed=4
var marqueecontents='<div class=testoscroll><%= Replace(strtesto, "'", "\'") %></div>'
if (document.all)
document.write('<marquee direction="left" scrollAmount='+speed+' style="width:'+marqueewidth +';height:'+marqueeheight+'">' +marqueecontents+'</marquee>')
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout("window.onresize=regenerate",450)
intializemarquee()
}
}
function intializemarquee(){
document.cmarquee01.document.cmarquee02.document.write( marqueecontents)
document.cmarquee01.document.cmarquee02.document.close()
thelength=document.cmarquee01.document.cmarquee02.document.height
scrollit()
}
function scrollit(){
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
document.cmarquee01.document.cmarquee02.top-=speed
setTimeout("scrollit()",100)
}else{
document.cmarquee01.document.cmarquee02.top = marqueeheight
scrollit()
}
}
window.onload=regenerate2
</script>
</td>
</tr>
</table>







Stampa
Download 


