Dynamic JSON variable strings
I have variables coming in from JSON files via AJAX calls. Each file will have 3 variables for different background colours. Depending on which button is clicked the background will change colour to the value specified in the JSON file.
The variables in the file are like this:
"background1" : "#000",
"background2" : "#333",
"background3" : "#FFF"
What I need to be able to do is something like this:
$backgroundcolour = data.background + $buttonnumber;
But I can't seem to use it - and eval doesn't seem to work. I'm not sure about the correct syntax.
Any help on this would be much appreciated - thanks.