I dont know if the title is wrong... i dont know which term i should use to exaplain the desired result - the end result i am trying to achieve is this:
var data = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
}
]
I am trying to build this type of array inside a .each loop while getting the values from a form (that can grow in the amount of rows..)
Here is what i got now (which "doesnt work"):
// GET VALUES FROM TR
var cnt = 0;
var datasets = [];
$('.pie-table > tbody > tr').length;
$('.pie-table > tbody > tr').each(function() {
var ctrid = '#' + $(this).attr('id');
var size = $(ctrid).find('input#value').val();
var color = $(ctrid).find('input#color').val();
var hlight = $(ctrid).find('input#highlight').val();
var label = $(ctrid).find('input#label').val();
if (size.length > 0) {
datasets[cnt] = 'value: ' + size + ', color:"' + color + '", highlight: "' + hlight + '", label: "' + label + '"';
}
cnt++;
})
var pieData = [];
for (var key in datasets) {
pieData.push(datasets[key]);
};
How can i achive a structure similer to the example inside that loop?