Is there any way to create a variable, and add an ID to the end of the actual variable name?
I have a variable called ‘gauge’, used to create a new Gauge object:
var gauge = new Gauge(target).setOptions(opts);
I want to add an ID to the variable, so something like:
var gauge+id = new Gauge(target).setOptions(opts);
It’s because I’m creating a number of these objects, and have a specific ID already for each one, which I want to attach to the gauge object if possible?
All my code for this function is below, if it gives you a better idea of what i need to do:
function go(id, votes)
{
var val = $('#votes_'+id).text();
var target = document.getElementById('foo_'+id); // your canvas element
var gauge = new Gauge(target).setOptions(opts); // create sexy gauge!
gauge.maxValue = 100; // set max gauge value
gauge.animationSpeed = 20; // set animation speed (32 is default value)
var a=votes+0.5;
gauge.set(val); // set actual value
}
My main problem arises on the last line. It says gauge.set(val), and it only sets the last object, ignoring all the other ones…
Why don’t you just use an array, like this :