Visualizzazione dei risultati da 1 a 10 su 10
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209

    Recuperare i valori di un dictionary

    Salve,

    come posso manipolare un oggetto dictionary restituito da una funzione ?

    es.



    retTest_= retTest_ & fncPrelTest_(cnt, str, var, lenvalue, pos)



    Function fncPrelTest_(cnt, str, var, lenvalue, pos)

    Dim idx, vlu, dato, sep
    Dim a, d, i, s
    if pos > 0 then
    idx = Mid(var, 6, pos)
    vlu = right(var, lenvalue)
    dato = "STR=" & str & idx & "_" & vlu

    Set d = CreateObject("Scripting.Dictionary")
    d.Add idx, vlu
    a = d.Items ' Get the items.
    b = d.keys
    For i = 0 To d.Count -1
    s = s & str & b(i) & "," & a(i) & "
    "
    Next
    fncPrelTest_ = s
    end if
    End Function



    io devo recuperare i valori

    test_3,5
    test_1,3
    test_0,2
    test_2,4

    contenuti nell' oggetto dictionary in modo da valorizzare i campi sottostanti nel seguente modo



    test0=2
    test1=3
    test2=4
    test3=5


    Il primo valore dopo il carattere "_" è l'indice

    Come posso fare ?

  2. #2

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209
    ciao optime

    ho provato con request.form(i).name ma non mi restituisce niente.

    Provo a rispiegare quale soluzione tentavo di adottare.

    Nella funzione sottostante...

    Function fncPrelTest_(cnt, str, var, lenvalue, pos)

    Dim idx, vlu, dato, sep
    Dim a, d, i, s
    if pos > 0 then
    idx = Mid(var, 6, pos)
    vlu = right(var, lenvalue)
    dato = "STR=" & str & idx & "_" & vlu

    Set d = CreateObject("Scripting.Dictionary")
    d.Add idx, vlu
    a = d.Items ' Get the items.
    b = d.keys
    For i = 0 To d.Count -1
    s = s & str & b(i) & "," & a(i) & "
    "
    Next
    fncPrelTest_ = s
    end if
    End Function

    valorizzo il dictionary aggiungendo un indice rappresentato dal primo numero dopo il carattere "_" e dal valore associato a quell'indice.
    Questi valori li catturo da campi creati dinamicamente in javascript.

    I valori sottostanti sono il risultato di una response.write

    test_3,5
    test_1,3
    test_0,2
    test_2,4

    Questi valori li devo recuperare ed assegnare a dei campi che dovranno implementare una tabella

    I campi che devo realizzare sono del tipo

    test0=2
    test1=3
    test2=4
    test3=5


    dove test0=2 è l'assegnazione che devo fare ad una variabile partendo dal valore del dictionary corrispondente a test_0,2.

    Spero di essere stato più chiaro di prima.
    Scusa per l'approssimazione ma sono sulle spine.

    Grazie

  4. #4
    non capisco COSA vuoi fare

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209
    voglio assegnare i valori

    test_3,5
    test_1,3
    test_0,2
    test_2,4

    presenti nel dictionary, a delle variabili.
    Nel form io ho un campo di input Test che recupero con request.form
    e n campi test che creo con javascript e che scorro con quest codice

    <%
    For Each i In Request.form

    var=i & "_" & Request.Form(i)
    'response.write "VAR=" & (var) & "
    "
    Str = Mid(var, 1, 5)
    if str="test_" then 'or str="quan_" or str="data_" then
    lth=len(var) 'lunghezza della stringa composta da nome campo "test", separatore "_", indice "1", separatore "_" e valore "3"
    tot=instrrev(var,"_")'posizione del 2 carattere separatore
    lenvalue=(lth-tot) 'la lunghezza in caratteri del valore
    pos=(tot-len(str)-1) 'numero di caratteri di cui è composto l'indice
    retTest_= retTest_ & fncPrelTest_(cnt, str, var, lenvalue, pos)
    response.write(retTest_)
    end if

    Next
    %>



    La funzione sottostante



    Function fncPrelTest_(cnt, str, var, lenvalue, pos)

    Dim idx, vlu, dato, sep
    Dim a, d, i, s
    if pos > 0 then
    idx = Mid(var, 6, pos)
    vlu = right(var, lenvalue)
    dato = "STR=" & str & idx & "_" & vlu

    Set d = CreateObject("Scripting.Dictionary")
    d.Add idx, vlu
    a = d.Items ' Get the items.
    b = d.keys
    For i = 0 To d.Count -1
    s = s & str & b(i) & "," & a(i) & "
    "
    Next
    fncPrelTest_ = s
    end if
    End Function


    mi carica il dictionary con i seguenti valori

    io devo recuperare i valori

    test_3,5
    test_1,3
    test_0,2
    test_2,4

    che io devo valorizzare come ho detto in variabili nel seguente modo


    test0=2
    test1=3
    test2=4
    test3=5

    Ti prego dimme che mi sono spiegato altrimenti non so più come dirla.

  6. #6
    ma lo SCOPO quale è? recuperare valori di un form?

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209
    lo scopo è recuperare i valori di alcuni campi di un form creati dinamicamente con javascript

  8. #8
    ok. lasciati ispirare da questo snippet

    codice:
    <%
    
    For Each formField in Request.Form
       Response.write "il valore del campo [" & formField & "] è...: " & Request.Form(formField) & "
    "
    Next
    
    %>
    ho capito che non devi leggere tutto, ma solo alcuni campi. formField è il nome del campo: testalo e - se corrisponde ai criteri - estrailo

    facce sape'

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209
    grazie mi sei stato di aiuto
    ...se vedimio.

  10. #10
    guarda in firma come ringraziare

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 © 2026 vBulletin Solutions, Inc. All rights reserved.