I previously posted a version of this question (JS - Constructor referencing) and found out the answer within the duplicates, especially Access / process (nested) objects, arrays or JSON. From here, I'm still having a ridiculous amount of time getting this to work as intended.
Given the following example code:
function f1(args) {
this.defaults = {
param1 : 100,
param2 : 900;
}
this.ranges = {
param1 : { min : 0, max : 500 },
param2 : { min : 0, max : 1000 };
}
this.steps = {
param1 : 50,
param2 : 100;
}
var myF1 = new f1();
I've read up on the previous duplicates and learning accessing the unknown property names by:
for (var propertyName in myF) {
newName = propertyName;
}
What I need to do is cycle through the function (or any function) and build HTML5 range inputs for the function (keep in mind that the parameter names will be greatly different or random, so I assume I need to loop for the key itself. So, in the case of f1
/myF1
, the generated HTML5 would be:
param1: <input type="range" name="param1" min="0" max="500" steps="50" />
param2: <input type="range" name="param2" min="0" max="1000" steps="100" />
Note: The values for range=, name=, min=, max= and step= are all dynamically generated from the function's properties.
I've tried looping for keys, calling for values and pretty much any other research and attempt I can, but I always end up with variables overwriting themselves and I'm guessing this is just more in the deep end than this amateur swimmer can figure out.
Also, realize that each parameter will have a defaults
, ranges
and steps
, so it is not like we have to worry about THAT level of randomization or variation. Thank you SO-JS gurus!