var currentCol = 0; function addCol() { var newColNumber = currentCol + 1; var html = "
"; html += "Column " + newColNumber+""; html += "=>"+""; html += "$env[csv][]"; html += "
"; jQuery("#rows").append(html); cols.push("col" + newColNumber); currentCol++; return newColNumber; } function initCols() { jQuery.each(cols, function(index, value) { var colNumber = addCol(); jQuery("#colVariable_" + colNumber).val(value); }); } initCols();