$(function() { setTimeout( "$('#alert').fadeOut('slow')", 4000 ); $('.id_taglia').change(function() { var oID_Riga = $(this).attr('id').substr(10); var oCarrello = $(this).attr('title'); fAggiornaRiga( oID_Riga, 'id_taglia', oCarrello, 0 ); }); $('.id_colore').change(function() { var oID_Riga = $(this).attr('id').substr(10); var oCarrello = $(this).attr('title'); fAggiornaRiga( oID_Riga, 'id_colore', oCarrello, 0 ); }); $('.linkToTest').click(function() { var oID_Riga = $(this).attr('id'); var oCarrello = $('#quantita_'+oID_Riga).attr('title'); var oLinkHref = $(this).attr('href'); $(this).attr( 'href' , oLinkHref + '&quantita=' + $('#quantita_'+oID_Riga).val() ); }); }) //--- Aggiorna riga carrello in base a taglia, colore e quantita' function fAggiornaRiga( pintRiga , pstrCampo , pstrCarrello , pintDownloads ) { if( pstrCampo == "quantita" && pintDownloads ) { $('#quantita_'+pintRiga).val( 1 ); $('#alert').html("Sie können die Menge der Produkte zum Download nicht ändern."); $('#alert').show(); setTimeout( "$('#alert').fadeOut('slow')", 4000 ); } else { ostrCommand = ( pstrCarrello == "sessione" ? "setRigaSessione" : "setRigaCliente" ); $('#preloadCarrello').html('loader'); $.ajax({ url: 'include/ajax/setCarrello.php' ,data: 'command=' + ostrCommand + '&id_riga=' + pintRiga + '&campo=' + pstrCampo + '&id_prodotto=' + $('#id_prodotto_'+pintRiga).html() + '&id_taglia=' + $('#id_taglia_'+pintRiga).val() + '&id_colore=' + $('#id_colore_'+pintRiga).val() + '&quantita=' + $('#quantita_'+pintRiga).val() + '&carrello=' + pstrCarrello ,success: function(data) { update = data.split('|'); if( update[0] == ostrCommand ) { if ( update[1] ) location.href = "cart.php"; $('#preloadCarrello').html(''); } } }); } }