Visualizzazione dei risultati da 1 a 8 su 8

Discussione: problema variabile

  1. #1

    problema variabile

    perche se creo un script in questo modo:
    <SCRIPT language="javascript">
    var vb2jsstr;
    vb2jsstr = new String("ciao");
    vb2jsstr = vb2jsstr.replace("ciao","1");
    <%="asd"%> = vb2jsstr;
    </SCRIPT>

    quasndo vado a vedere html lui dentro asd mi mette "vb2jsstr" nn dovrebbe mettermi 1?

  2. #2
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    infatti mette 1
    codice:
    <SCRIPT language="javascript"> 
    var vb2jsstr; 
    vb2jsstr = new String("ciao"); 
    vb2jsstr = vb2jsstr.replace("ciao","1"); 
    <%="asd"%> = vb2jsstr; 
    document.write(asd)
    </SCRIPT>

  3. #3

  4. #4
    ok mi stavo confondendo lavoro troppo e poi mi fonde tutto qua eheh cmq:
    var vb;vb1;vb2;vbtotal;
    var vb2jsi = "ciao";
    var vb2jsj = "mamma";

    vb = new String(vb2jsi + vb2jsj);
    vb = vb.replace("\","\\");

    vb1 = new String(vb2jsi + vb2jsj);
    vb1 = vb1.replace("'","\'");

    vb2 = new String(vb2jsi + vb2jsj);
    vb2 = vb2.replace("
    ","1");


    vbtotal = vb+vb1+vb2
    mi da errore carattere nn valido, ho sbagliato qualcosa?

  5. #5
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    correggo
    codice:
    var vb,vb1,vb2,vbtotal
    var vb2jsi = "ciao";
    var vb2jsj = "mamma";
    	
    vb = new String(vb2jsi + vb2jsj);
    vb = vb.replace(/\\/g,"\\\\");
    	
    vb1 = new String(vb2jsi + vb2jsj);
    vb1 = vb1.replace(/'/g,"\'");
    	
    vb2 = new String(vb2jsi + vb2jsj);
    vb2 = vb2.replace(/
    /g,"1");
    	
    vbtotal = vb+vb1+vb2

  6. #6
    il problema di fondo e': che s eio provo via asp a stampare vbtotal mi da errore, l'unico modo e' con document.write, dato che poi sto vbtotal va dentor un array, cosi facendo l'array non viene valorizzato!

  7. #7
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    non ho capito niente :master:
    asp è lato server e javascript è lato client... è normale che tu non possa stampare in asp una variabile javascript

  8. #8
    anche tu hai ragione guarda posto l'intero codice cosi vediamo cosa si puo' fare..

    <SCRIPT LANGUAGE = 'JAVASCRIPT' >
    var vb2jsi,vb2jsj
    <%=ArrayName%> = new Array(<%=vb2jsRow+1%>);
    for (vb2jsi=0; vb2jsi < <%=vb2jsRow+1%>; vb2jsi++)
    {
    <%=ArrayName%>[vb2jsi] = new Array(<%=vb2jsCol+1%>)
    for (vb2jsj=0; vb2jsj < <%=vb2jsCol+1%>; vb2jsj++) <%=ArrayName%>[vb2jsi][vb2jsj] = " "
    }
    </SCRIPT>
    ----------------LATO SERVER/CLIENT--------------
    <%
    Response.Write("<SCR"&"IPT LANGUAGE = 'JAVASCRIPT' >"&chr(13))
    Response.Write ("var vb2jsstr;")
    Response.Write ("var vb2jsi;")
    Response.Write ("var vb2jsRow;")
    Response.Write ("var vb2jsCol;")
    Response.Write ("var vb2jsj;")
    for vb2jsi=0 to vb2jsRow
    for vb2jsj=0 to vb2jsCol
    vb2jsstr = "VBArray("&vb2jsi&","&vb2jsj&")"
    vb2jsstr = replace(vb2jsstr,vbcrlf,"")
    ------------versione asp che ho implementato in questi giorni----
    %>
    <%=ArrayName%>[<%=vb2jsi%>][<%=vb2jsj%>] = "<%=trim(eval(vb2jsstr))%>"
    ----------versione javascript che sto cercando di far funzionare--
    vb2jsstr = new String(<%=vb2jsi%> + <%=vb2jsj%>);
    vb2jsstr = vb2jsstr.replace(/na/g,"'");
    <%=ArrayName%>[<%=vb2jsi%>][<%=vb2jsj%>] = vb2jsstr;
    <%
    Next
    Next
    Response.Write("</SCR"&"IPT>")
    %>

    il mio problema e' che lato server l'array se faccio visualizza html si vedono i dati all'interno lato client io visualizzodentro l'array la variabile e mi da array vuoto.

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.