Kelvineger

index.php

Oct 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.68 KB | None | 0 0
  1. <head>
  2.     <title>Pede Aqui</title>
  3.     <meta charset="UTF-8">
  4.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5.     <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  6.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">
  7.     <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  8.     <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>
  9. </head>
  10. <body>
  11.     <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
  12.  
  13.     <script type="text/javascript">
  14.         $(document).ready(function () {
  15.             lista();
  16.             $("input[name=enviar]").click(function () {
  17.                 var nome = $("input[name=nome]").val();
  18.                 var descri = $("input[name=descri]").val();
  19.                 envia(nome, descri);
  20.                 lista();
  21.             });
  22.  
  23.             $("input[name=excluir]").click(function () {
  24.                 var nome = $("input[name=excluir]").val();
  25.                 exclui(nome);
  26.                 lista();
  27.             });
  28.         });
  29.  
  30.         function lista() {
  31.             $.ajax({
  32.                 url: 'listaclasse.php',
  33.                 success: function (data) {
  34.                     $(".lista").html(data);
  35.                 }
  36.             });
  37.         }
  38.  
  39.         function exclui(nome) {
  40.             info = {"nNome": nome};
  41.             $.ajax({
  42.                 type: 'post',
  43.                 url: 'excluiclasse.php',
  44.                 data: info,
  45.             }).done(function (data) {
  46.                 $(".resposta h3").text(data);
  47.                 console.log("chegou aqui");
  48.             });
  49.         }
  50.  
  51.         function envia(nome, descri) {
  52.             info = {"nNome": nome, "nDescri": descri};
  53.             $.ajax({
  54.                 type: 'post',
  55.                 url: 'cadastraClasse.php',
  56.                 data: info,
  57.             }).done(function (data) {
  58.                 $(".resposta h3").text(data);
  59.             });
  60.         }
  61.     </script>
  62.  
  63.     <form id="formulario">
  64.         <div class="container">
  65.             <label>Classe: <input type="text" name="nome" placeholder="Classe"/></label>
  66.             <label>Descrição curta: <input type="text" name="descri" placeholder="Descrição curta"/></label>
  67.             <input type="button" name="enviar" value="Enviar" placeholder="Enviar"/>
  68.             <input type="button" name="listar" value="Listar" onclick="lista()" placeholder="Lista"/>
  69.         </div>
  70.     </form>
  71.     <div class="resposta">
  72.         <h3></h3>
  73.     </div>
  74.  
  75.  
  76.     <div class="lista">
  77.  
  78.     </div>
  79. </body>
Add Comment
Please, Sign In to add comment