| 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 type="hidden" name="id"> |
| 24 | |
| 25 | <p> |
| 26 | <label> |
| 27 | Nombre * |
| 28 | <input name="nombre" value="Cargando…"> |
| 29 | </label> |
| 30 | </p> |
| 31 | |
| 32 | <p> |
| 33 | <label> |
| 34 | Pasatiempo |
| 35 | <select name="pasId"> |
| 36 | <option value="">Cargando…</option> |
| 37 | </select> |
| 38 | </label> |
| 39 | </p> |
| 40 | |
| 41 | <p>* Obligatorio</p> |
| 42 | |
| 43 | <p> |
| 44 | |
| 45 | <button type="submit">Guardar</button> |
| 46 | |
| 47 | <button id="botonEliminar" type="button"> |
| 48 | Eliminar |
| 49 | </button> |
| 50 | |
| 51 | </p> |
| 52 | |
| 53 | </form> |
| 54 | |
| 55 | <script type="module"> |
| 56 | |
| 57 | import { descargaVista } from "./js/lib/descargaVista.js" |
| 58 | import { submitAccion } from "./js/lib/submitAccion.js" |
| 59 | import { accionElimina } from "./js/lib/accionElimina.js" |
| 60 | |
| 61 | const params = new URL(location.href).searchParams |
| 62 | descargaDatos() |
| 63 | |
| 64 | async function descargaDatos() { |
| 65 | |
| 66 | if (params.size > 0) { |
| 67 | |
| 68 | await descargaVista("php/amigo-vista-modifica.php?" + params) |
| 69 | |
| 70 | formulario.addEventListener( |
| 71 | "submit", |
| 72 | event => submitAccion( |
| 73 | event, "php/amigo-modifica.php", formulario, "index.html" |
| 74 | ) |
| 75 | ) |
| 76 | |
| 77 | botonEliminar.addEventListener( |
| 78 | "click", |
| 79 | () => accionElimina( |
| 80 | "php/amigo-elimina.php", |
| 81 | formulario, |
| 82 | "Confirma la eliminación", |
| 83 | "index.html" |
| 84 | ) |
| 85 | ) |
| 86 | |
| 87 | } |
| 88 | |
| 89 | } |
| 90 | |
| 91 | </script> |
| 92 | |
| 93 | </body> |
| 94 | |
| 95 | </html> |