JS reference to the parent object
Hi,
I have a grid of tiles. The tiles are called: box_01, box_02, etc. I'm writing a JS script to access values that are under variables: box_01_value, box_02_value, etc.
Is there any way to reference the object to get the name of the variable I want the value from, eg.
When a user clicks on box: "box_01", the script would get the value from variable "box_01_value". Obviously I could do it specifically for each box, but that's not what programming is about. Is there a way of making it more abstract generic so the code is the same for each box, eg:
alert(self + "_value");
Additionally, is there any update on the js loop problem with captivate js window? As read on this forum about the < sign, I've redone the loop to use > but still no luck. The code works fine outside Captivate. In the end I had to hard code it (which again defeats the purpose of writing code a bit).
var L = ['A', 'B', 'C', 'D'];
var suff = '_value';
var grid = [];
var min = 1;
var max = 5;
for (var i = L.length-1; i>=0; i--) {
for (var j = L.length-1; j>=0; j--) {
grid.push(L + String(j+1) + suff)
}
}
alert(grid);
The output is:
[ 'D4_value',
'D3_value',
'D2_value',
'D1_value',
'C4_value',
'C3_value',
'C2_value',
'C1_value',
'B4_value',
'B3_value',
'B2_value',
'B1_value',
'A4_value',
'A3_value',
'A2_value',
'A1_value' ]
Thank you.
