Array conversion error in jquery
hi following is a working examplevar totals = [0, 0, 0, 0, 0, 0];
var $dataRows = $("#GridViewProfit tr:not('.totalColumn, .titlerow')");
$dataRows.each(function () {
$(this).find('.rowDataSd').each(function (i) {
var k = parseInt($(this).html());
if ($(this).html() != '') {
totals[i] += parseInt($(this).html());
console.log(totals[i]);
$("#GridViewProfit tr:last td").eq(i + 1).html(totals[i]).css('background-color', 'white');
}
});
});
This code is for calculate the sum of values in columns and display at the bottom of each columns
here iam directly declare totals as
var totals=[0,0,0,0,0,0];
my requirement is to create totals dynamically
like following code
var str;
var l = $('#GridViewProfit tr th').length - 1;
str = '[';
for (k = 0; k < l; k++) {
str += "0" + ' ,';
}
var bb = str;
bb = bb.slice(0, -1);
bb += ']';
bb = bb.substring(-1, bb.length);
totals=bb;
here iam getting totals=[0,0,0,0,0,0]
but it is not working
i have checked totals using console.log and alert then it is showing [0,0,0,0,0,0]
when i check with debugger in IE
then totals showing as "[0,0,0,0,0,0]"
both quotes are not showing in console.log and alert
how to solve this
Regards
Baiju