Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does the set statement create a reference or copy of an object?

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I assumed that the the SET statement created a reference to an object rather than a copy of it. But I'm getting weird results from the following code.
Code:
Dim oSelect

Function abc()
    Set oSelect = document.getElementById("MyListBox")

    oSelect.outerHTML = "SELECT..."
End Function
What's weird is the document.getElementById("MyListBox").outerHTML contains the new value I assigned in the code (i.e. oSelect.outerHTML = "SELECT..."). However, oSelect.outerHTML does not contain the new value I assigned in the code (i.e. "SELECT..."). Rather it still contains the old value.

Is this expected behavior or am I missing something?
 
I forgot to point out that this code is within a class. So it looks more like this:
Code:
Class myclass
    Dim oSelect

    Function abc()
        Set oSelect = document.getElementById("MyListBox")

        oSelect.outerHTML = "SELECT..."
    End Function
End Class
 
I can only say if you want to modify elements at runtime after the document is being loaded, you go about with proper dom methods. Use innerHTML to change text node value is more secure, other than that, when the "all" collection or dom structure are changed at runtime, it is very uncertain to do with innerHTML, even less with outHTML.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top