$(document).ready(function(){ function datiTabella(that){ $('.menu-tabella').removeClass('active'); $(that).addClass('active'); $('#tabella').empty(); var html = ''; html += ''; html += ''; //html += ''; html += ''; html += ''; $('#tabella').html(''); $.getJSON('/grafici/tabella.php', 'c=27&lang=', function(data, textStatus, jqxhr){ var anno = $('.menu-tabella.active').attr('id'); $.each(data, function(i, obj){ if(obj.anno == anno || anno == 'all'){ html += ''; html += ''; html += ''; //html += ''; html += ''; } }); html += ''; html += '
MeseValore quota (€)Patrimonio (€)
' + obj.data + '' + (obj.valore? obj.valore: '') + '' + (obj.andp? obj.andp: '') + '
'; $('#tabella').html(html); }); return false; } function menuAnni(){ var anno; var html = ''; $('#tabellaMenu').empty(); $.getJSON('/grafici/tabella.php', 'c=27&lang=&a=5', function(data, textStatus, jqxhr){ var first = true; $.each(data, function(i, obj){ if(obj.anno != anno && obj.anno > 1){ html += '' + obj.anno + ''; anno = obj.anno; first = false; } }); $('#tabellaMenu').html(html).append('Tutti'); $('.menu-tabella').on('click', function(e){ return datiTabella(this); }); datiTabella($('.menu-tabella.active')); }); } menuAnni(); });