Reputation: 302
finalVariables() returns an object that contains data accessible by .dataName notation i.e. finalVariables().mainViewWindow0 returns the string stored for mainViewWindow0. I'm trying to access mainViewWindow0 using a dynamically created variable, but for obvious reasons this doesn't work so well with dot notation, but I don't know how to work around it. Help to be had for me?
Please ignore the poor coding practice of having a hard-coded number in there; I promise to get rid of it later
activePane = dot.id.substring(6); //gets dot # and sets it as active pane
var tempForPaneNumber = "mainViewWindow" + activePane + "";
document.getElementById("mainViewWindowContent").innerHTML = finalVariables().@@@this is where I want to use
the string from "tempForPaneNumber" to access @@@
Upvotes: 0
Views: 24
Reputation: 10804
In Javascript you can access properties of an object either through the dot notation or through the use of brackets to specify the identifier for the property so myVar.foo
is equivalent to myVar['foo']
. Therefore, if I understand what you are asking correctly you want to use finalVariables()[tempForPaneNumber]()
Upvotes: 1
Reputation: 1716
finalVariables[tempForPainNumber]()
Should do the trick if I understand correctly.
Upvotes: 1