J. modifica.html

1
<!DOCTYPE html>
2
<html lang="es">
3
4
<head>
5
6
 <meta charset="UTF-8">
7
 <meta name="viewport" content="width=device-width">
8
9
 <title>Modificar</title>
10
11
 <script type="module" src="js/lib/manejaErrores.js"></script>
12
13
</head>
14
15
<body>
16
17
 <form id="formulario">
18
19
  <h1>Modificar</h1>
20
21
  <p><a href="index.html">Cancelar</a></p>
22
23
  <input name="id" type="hidden">
24
25
  <p>
26
   <label>
27
    Nombre *
28
    <input name="nombre" value="Cargando…">
29
   </label>
30
  </p>
31
32
  <p>* Obligatorio</p>
33
34
  <p>
35
36
   <button type="submit">Guardar</button>
37
38
   <button id="botonEliminar" type="button">
39
    Eliminar
40
   </button>
41
42
  </p>
43
44
 </form>
45
46
 <script type="module">
47
48
  import { descargaVista } from "./js/lib/descargaVista.js"
49
  import { submitAccion } from "./js/lib/submitAccion.js"
50
  import { accionElimina } from "./js/lib/accionElimina.js"
51
52
  // Obtiene los parámetros de la página.
53
  const params = new URL(location.href).searchParams
54
  descargaDatos()
55
56
  async function descargaDatos() {
57
58
   if (params.size > 0) {
59
60
    await descargaVista("php/pasatiempo-vista-modifica.php?" + params)
61
62
    formulario.addEventListener(
63
     "submit",
64
     event => submitAccion(
65
      event, "php/pasatiempo-modifica.php", formulario, "index.html"
66
     )
67
    )
68
69
    botonEliminar.addEventListener(
70
     "click",
71
     () => accionElimina(
72
      "php/pasatiempo-elimina.php",
73
      formulario,
74
      "Confirma la eliminación",
75
      "index.html"
76
     )
77
    )
78
79
   }
80
81
  }
82
83
 </script>
84
85
</body>
86
87
</html>
skip_previous skip_next