0

ここの誰かがASPコレクションをJavascriptコレクションに保存する方法を知っていますか?以前の投稿からコードを取得しましたが、機能しませんでした。コードを間違った場所に配置したに違いありません。

現在、ドキュメントの準備が整うと、ASPコレクションの各変数が一度に1つずつ下に移動するアプリを開発しています。slideDownイベントがあるため、jqueryを使用して各値をスライドダウンすることにしました。しかし、私が下にスライドすると、コレクションのアイテムがすべて同時に下にスライドします。ここの誰かがこれを行う方法についてのアイデアやこれを行うためのより良い方法についての提案を持っていますか?

<%

        Dim objDictionary, Key,searchWord, myVar,a,i, break
        searchWord = request.QueryString("searchWord")



        Set objDictionary = CreateObject("Scripting.Dictionary")
        objDictionary.CompareMode=1
        objDictionary.Add "Hello","hello"
        objDictionary.Add "Age","age"
        objDictionary.Add "height","height"
        objDictionary.Add "sample","sample"
        objDictionary.Add "words","words"


        Response.Write "<div id='toFall'>"
        if objDictionary.Exists(searchWord) then
            objDictionary.Remove(searchWord)
           a = objDictionary.Keys


            for i=0 to objDictionary.Count-1
            Response.Write( "<div class='fall'>" + a(i)) 
            Response.write("<br />")
            Response.write("</div>")

            next
            set objDictionary=nothing
        else 
            a = objDictionary.Keys

            for i=0 to objDictionary.Count-1
            Response.Write( "<div class='fall'>" + a(i)) 
            Response.write("<br />")
            Response.write("</div>")
            next
            set objDictionary=nothing

        end if      

        Response.write "</div>" 

'got this code from my previous post but didn't got it working  
        Sub CollectionToJavaScript(oCollection, sClientSideName) 
            Dim blnFirst
            blnFirst = True
            Response.Write("<" & "script" & " type=""text/javascript"">")
            Response.Write("var " & sClientSideName & " = {")
            For Each key In objDictionary.Keys
                If Not(blnFirst) Then Response.Write(", ")
                Response.Write( key & ": " & objDictionary(key) )
                blnFirst = false
            Next
            Response.Write("};")
            Response.Write("</" & "script>")
            Call CollectionToJavaScript (objDictionary, "myCollection")
        End Sub



        %>
4

1 に答える 1

0

コードにいくつかの間違いがありました:

  1. CollectionToJavaScript subを呼び出す前に、ディクショナリオブジェクトを何にも設定していませんでした
  2. CollectionToJavaScriptサブ内でoCollectionを使用する必要がありました
  3. Response.Write(key& ":"&objDictionary(key))
    blnFirst=falseの位置付け

    <%    
    Dim objDictionary, Key,searchWord, myVar,a,i, break         
    searchWord = request.QueryString("searchWord")            
    
    Set objDictionary = CreateObject("Scripting.Dictionary")         
    objDictionary.CompareMode=1         
    objDictionary.Add "Hello","hello"         
    objDictionary.Add "Age","age"         
    objDictionary.Add "height","height"         
    objDictionary.Add "sample","sample"         
    objDictionary.Add "words","words"           
    
    Response.Write "<div id='toFall'>"         
    
    if objDictionary.Exists(searchWord) then     
    
        objDictionary.Remove(searchWord)            
        a = objDictionary.Keys               
        for i=0 to objDictionary.Count-1             
            Response.Write( "<div class='fall'>" + a(i))              
            Response.write("<br />")             
            Response.write("</div>")              
        next                    
    
    else   
    
        a = objDictionary.Keys              
        for i=0 to objDictionary.Count-1             
            Response.Write( "<div class='fall'>" + a(i))              
            Response.write("<br />")             
            Response.write("</div>")             
        next                   
    
    end if                
    
    Response.write "</div>"   'got this code from my previous post but didn't got it working           
    
    Sub CollectionToJavaScript(ByRef oCollection, sClientSideName)              
    Dim blnFirst             
    blnFirst = True             
    
        Response.Write("<" & "script" & " type=""text/javascript"">")             
        Response.Write("var " & sClientSideName & " = {")             
    
        For Each key In oCollection.Keys                 
        If Not(blnFirst) Then 
            Response.Write(", ")                       
        End If    
        Response.Write( key & ": " & oCollection(key) )     
        blnFirst = false       
        Next   
    
    Response.Write("};")             
    Response.Write("</" & "script>")             
    End Sub          
    
    Call CollectionToJavaScript (objDictionary, "myCollection")    
    
    set objDictionary=nothing      
    
    %>
    
于 2012-08-31T08:28:09.913 に答える