$(document).ready(function(){ var requisitaJson = function () { $('.registros').removeClass('selected'); $(this).addClass('selected'); $('#tabella').empty(); var html = ''; html += ''; html += ''; html += ''; html += ''; var rand = Math.floor(Math.random() * 1000); $.getJSON('/grafici/tabella.php?c=27&' + rand, function(data){ $('#tabella').empty(); var numeroRegistros = $('.registros.selected').attr('id'); $.each(data, function (i, obj) { //Originale //if(obj.anno == numeroRegistros || numeroRegistros == 'all'){ //Inserimento di variante per visualizzare il dicembre anno precedente nella tabella var annoprecedente = numeroRegistros - 1; if(obj.anno == numeroRegistros || numeroRegistros == 'all' || obj.data.indexOf("dicembre " + annoprecedente) != -1 ){ html += ''; html += ''; html += ''; html += ''; } }); html += ''; html += '
MeseValore quota (€)
' + obj.data + '' + obj.valore + '
'; $('#tabella').append(html); }); return false; }; var menuAnni = function () { var annoattuale; var htmlMenu = ''; $('#tabellaMenu').empty(); var rand = Math.floor(Math.random() * 1000); $.getJSON('/grafici/tabella.php?c=27&a=11&' + rand, function(data){ var first = true; $.each(data, function (i, obj) { if(obj.anno != annoattuale && obj.anno > 1){ htmlMenu += ''+ obj.anno +' '; annoattuale = obj.anno; first = false; } }); $('#tabellaMenu').html(htmlMenu).append('Tutti'); $('.registros').bind('click', requisitaJson); $('.registros.selected').trigger('click'); }); }; menuAnni(); });