0

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

1
  • Thanks guys! Was hoping it was something simple like that Commented Mar 26, 2015 at 23:35

2 Answers 2

1
finalVariables[tempForPainNumber]()

Should do the trick if I understand correctly.

Sign up to request clarification or add additional context in comments.

Comments

1

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]()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.