$(document).ready(function() { $('.changeEtat').each(function(){ var $link = $(this); var $dialog = $('
') .dialog({ autoOpen: false, title: $link.attr('title'), width: 400, height: 200, open: function(event, ui) { $(this).load($link.attr('href')); }, buttons: { 'Placer la commande en erreur': function() { $.post('./pages/greffescmd.php', { idCommande: $('input[name=idCommande]').val(), commentaire: $('textarea[name=commentaire]').val(), statutCommande: $('input[name=statutCommande]').val(), submit: 'comment' }, function(data){ if(data==1){ $dialog.dialog('close'); } else $('#message').html('Erreur...'); } ); }, 'Annuler': function() { $(this).dialog('close'); } } }); $link.click(function() { $dialog.dialog('open'); return false; }); }); $('.changeEtatC').change(function(){ var newEtat = $(this).val(); var name = $(this).attr('name'); $.post('./pages/ajax/greffescmd_courrier.php', { changeEtat: newEtat }, function(data){ $('select[name='+name+']').replaceWith(data); } ); }); $('.rs').click(function(e){ e.preventDefault(); var element = $(this); var siren = $(this).attr('alt'); $.post('./pages/greffescmd.php?rs', { siren: siren }, function(data){ element.replaceWith(''+data+''); } ); }); });