Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    passare array a javascript

    salve uso uno script per fare lo scroll dei link in una pagina aspx. ho dei problemi con il passaggio dell'array al javascript.
    riporto il codice

    <%
    Dim vettore_stringhe=new ArrayList(3)
    vettore_stringhe.Add("Il forum di HTML.it")
    vettore_stringhe.Add("Il forum di HTML.it")
    vettore_stringhe.Add("Il forum di HTML.it")


    %>
    <script type="text/javascript">

    //configure the below five variables to change the style of the scroller
    var scrollerdelay='3000' //delay between msg scrolls. 3000=3 seconds.
    var scrollerwidth='150px'
    var scrollerheight='105px'
    var scrollerbgcolor='#0E1B8D'
    //set below to '' if you don't wish to use a background image
    var scrollerbackground=''

    //configure the below variable to change the contents of the scroller (basta aggiungere una riga cambiare numero di variabile)
    var messages=new Array('<%=vettore_stringhe%>')


    nella pagina non viene visualizzato il testo che ho messo nel vettore ma sempre la scritta
    System.Collections.ArrayList


    dove sbaglio???

  2. #2
    sono riuscito a passare il valore usando questo codice

    <%
    Dim vettore_stringhe=new ArrayList()
    dim quantilink as integer
    dim i as integer
    i=0
    quantilink=0
    cn.open()
    cmd = new Sqlcommand("select * from quicklinks where attivo=1 and lingua='" + session("lingua") +"' order by id desc",cn)
    res=cmd.executereader

    while (res.Read())
    vettore_stringhe.Add("<font face='Verdana' >" & res(2) & "</font>")
    quantilink=quantilink+1
    end while

    cn.close()


    %>
    <script type="text/javascript">

    //configure the below five variables to change the style of the scroller
    var scrollerdelay='3000' //delay between msg scrolls. 3000=3 seconds.
    var scrollerwidth='150px'
    var scrollerheight='105px'
    var scrollerbgcolor='#0E1B8D'
    //set below to '' if you don't wish to use a background image
    var scrollerbackground=''

    //configure the below variable to change the contents of the scroller (basta aggiungere una riga cambiare numero di variabile)
    var messages=new Array()
    for (j=0; j<<%=quantilink%>; j++) {
    messages[j]="<%response.write(vettore_stringhe(i))%>"
    }
    il problema è che mi prende sempre la prima stringa dell'array vettore_stringhe perchè non riesco ad incrementare quel valore di i


  3. #3
    risolto così...anche se forse è grezzo

    <div align="center">

    <script type="text/javascript">
    var messages=new Array()
    var j
    j=0
    <%
    Dim vettore_stringhe=new ArrayList()

    dim testo as string


    cn.open()
    cmd = new Sqlcommand("select * from quicklinks where attivo=1 and lingua='" + session("lingua") +"' order by id desc",cn)
    res=cmd.executereader

    while (res.Read())
    testo="<font face='Verdana' >" & res(2) & "</font>"


    %>

    messages[j]="<%response.write(testo)%>"
    j=j+1

    <%

    end while
    cn.close()

    %>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.