You must Sign In to post a response.
  • Category: JQuery

    Array conversion error in jquery

    hi following is a working example

    var 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());
    $("#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);

    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

  • #767635
    A List can be converted to an array. The opposite conversion is also needed. This is required in many programs—it is important to have it handy. We make sure the method works well. We look at it in the Visual Studio debugger
    <a href=""> Dot Net Training in chennai </a>

Sign In to post your comments