I'm working on an issue where I need to access the value and name of a buitenunit, binnenunit and boiler when certain conditions are met.
I have 4 different tables like this (almost similar) and when a condition is met I need to start searching data in 1 of the 4 tables. Take this table for example.
alpha| buitenunit binnenunit boiler
-----------------------------------------------------------------
4200 | ERLQ004CV3(value=100) EHBH04C3V(value=101) EHVH04S18C3V=(102)
6200 | ERLQ006CV3(value=200) EHBH04C3V(value=101) EHVH04S18C3V=(102)
8200 | ERLQ008CV3(value=300) EHBH04C3V(value=101) EHVH04S18C3V=(102)
11200| ERLQ011CV3(value=400) EHBH04C3V(value=101) EHVH04S18C3V=(102)
14200| ERLQ014CV3(value=500) EHBH04C3V(value=101) EHVH04S18C3V=(102)
Now I need corresponding buitenunit, binnenunit and boiler (and their values) depending on the alpha value.
For example, say alpha is 4200 then I need to show: "Your selected setup will be ERLQ004CV3, EHBH04C3V and EHVH04S18C3V and it will cost you (100+101+102) 303 coins.
For the moment I'm really confused how to get both value and name in way so I can easily access them.
This is what I have at the moment:
var alphas = ['4200', '6200', '8200', '11200', '14200', '17000'];
var buitenunit = ['ERLQ004CV3', 'ERLQ006CV3', 'ERLQ008CV3', 'ERLQ011CV3', 'ERLQ014CV3', 'ERLQ016CV3'];
var binnenunit = ['EHBH04C3V', 'EHBH08C3V', 'EHBH08C3V', 'EHBH16C3V', 'EHBH16C3V', 'EHBH16C3V'];
var boiler = ['EKHWS200B3V3', 'EKHWS200B3V3', 'EKHWS200B3V3', 'EKHWS200B3V3', 'EKHWS200B3V3', 'EKHWS200B3V3'];
var grid = {};
for(var i = 0; i < alphas.length; i++){
var alpha = alphas[i];
if(alpha in grid == false){
grid[alpha] = {};
}
var buitenunit = buitenunitlinksboven[i];
grid[alpha][buitenunit] = i;
var binnenunit = binnenunitlinksboven[i];
grid[alpha][binnenunit] = i;
var boiler = boilerlinksboven[i];
grid[alpha][boiler] = i;
}
But now the only way to access the value is if I already know the name of a unit. And the name is dependant on the alpha value.
So my question is: How would I store this kind of information in a way that it is easy accessible. Am I currently on the right track? I just thought of JSON, can JSON help me perhaps?
Amazing thanks to anybody taking the time to actually read this.
Greetings