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>
Commenti
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Approfondimenti
Utilizzare il metodo reduce in JavaScript
Gestire i file esterni in una PWA
3 metodi JavaScript che ogni applicazione web dovrebbe contenere - Parte 2
Creare un router per Single Page Application con l'evento navigate
3 metodi JavaScript che ogni applicazione web dovrebbe contenere
Ottimizzare il codice JavaScript utilizzando WeakMap e WeakSet
Recuperare un elemento inserito nella cache del browser tramite API JavaScript
Eseguire operazioni con timeout in React
Utilizzo di Set e Array in JavaScript
Confronto tra moduli in Javascript: ES e commonJS
Utilizzare flat e flatMap per appiattire array innestati in array
Utilizzare il tag HTML template