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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Variable names, values etc

Status
Not open for further replies.

JohnandSwifty

Technical User
May 31, 2005
192
GB
Hi,

I have read just about every post and article regarding this but for some reason im just not getting it right! arg

Can someone help me with the below:

I have an objects that store application settings across the modules in my application - for example - app.moduleName.contentName.settingName

i need to set these variables dynamically - so i pass a function moduleName, contentName and then the function performs whatever and then sets the relevant variable accordingly.

So what im trying to do is -
'app.' + moduleName + '.' + contentName + '.' + 'settingName' = settingName

And my attempt is -
var varName = 'app.' + moduleName + '.' + contentName + '.settingName';
window[varName] = value;

thanks


 
Sorry - i got there in the end. I was missing the dot before the final part of the variable name.

app[moduleName][contentName].settingName

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top