Advertisement
gilcierweb

Delete com confirm javascript, jquery e php

Nov 22nd, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. //php
  2. <?php
  3.  
  4. // Para conectar-se ao banco.
  5. require("../config.php");
  6.  
  7. $id_agendamento = $_GET['agendamento'];
  8.  
  9. $sql = "DELETE FROM agendamento WHERE id = $id_agendamento";
  10. $query = mysql_query($sql);
  11. //if ($query) {
  12. //    echo "alert('Agendamento Excluído com Sucesso!');";
  13. //}
  14. ?>
  15.  
  16. //javascript
  17. <script type="text/javascript">
  18.     $(document).ready(function() {  
  19.            
  20.         $("#agendamento_excluir").click(function(){  
  21.             alert( $("#agendamento_excluir").attr('href'));
  22.             var yes = confirm("Você tem certeza que deseja excluir esse agendamento");
  23.             if(yes)
  24.             {    
  25.                 $.get( $("#agendamento_excluir").attr('href'));
  26.                 alert('Agendamento Excluído com Sucesso!');
  27.                 window.location="./index.php?pagina=agenda";        
  28.             }
  29.             else
  30.             {
  31.                 window.location="./index.php?pagina=agenda";            
  32.             }
  33.             return false;                
  34.         });
  35.     });
  36. </script>
  37.  
  38. // html
  39. <a href="<?php echo "agendamento/agendamento_excluir.php?agendamento={$agendamento->getId()}"; ?>" id="agendamento_excluir"><img alt="Excluir" title="Excluir" src="atendimento/img/botao_excluir.gif" /></a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement