asp经典对象到javascript对象,并使对象向下滑动

asp classic object to javascript object and make objects slide down

本文关键字:对象 经典 javascript asp      更新时间:2023-09-26

这里有人知道如何将ASP集合存储到Javascript集合吗?我从上一篇文章中得到了一个代码,但没有把它用起来——我一定把代码放错了地方。

我目前正在开发一个应用程序,一旦文档准备好,ASP集合中的每个变量都会一次下移一个。我决定使用jquery来向下滑动每个值,因为它有一个slideDown事件。但当我向下滑动时,集合中的项目会同时向下滑动。这里有人对如何做到这一点有想法,或者对更好的方法有建议吗?

<%
        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

        %>

您的代码中有几个错误:

  1. 在调用CollectionToJavaScript子之前,您将dictionary对象设置为空
  2. 您需要在CollectionToJavaScript子中使用oCollection
  3. 的位置Response.Write(key&":"&objDictionary(key))
    blnFirst=错误

    <%    
    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      
    %>