I. 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="lib/js/consumeJson.js"></script>
12 <script type="module" src="lib/js/submitForm.js"></script>
13 <script type="module" src="lib/js/muestraError.js"></script>
14 <script type="module" src="lib/js/muestraObjeto.js"></script>
15
16 <script>
17 // Obtiene los parámetros de la página.
18 const params = new URL(location.href).searchParams
19 </script>
20
21</head>
22
23<body onload="if (params.size > 0) {
24 consumeJson('srv/pasatiempo-options.php')
25 .then(async options => {
26 const modelo = await consumeJson('srv/amigo.php?' + params)
27 muestraObjeto(document, options.body)
28 muestraObjeto(document, modelo.body)
29 })
30 .catch(muestraError)
31 }">
32
33 <form onsubmit="submitForm('srv/amigo-modifica.php', event)
34 .then(modelo => location.href = 'index.html')
35 .catch(muestraError)">
36
37 <h1>Modificar</h1>
38
39 <p><a href="index.html">Cancelar</a></p>
40
41 <input type="hidden" name="id">
42
43 <p>
44 <label>
45 Nombre *
46 <input name="nombre" value="Cargando…">
47 </label>
48 </p>
49
50 <p>
51 <label>
52 Pasatiempo
53 <select name="pasId">
54 <option value="">Cargando…</option>
55 </select>
56 </label>
57 </p>
58
59 <p>* Obligatorio</p>
60
61 <p>
62
63 <button type="submit">Guardar</button>
64
65 <button type="button" onclick="
66 if (params.size > 0 && confirm('Confirma la eliminación')) {
67 consumeJson('srv/amigo-elimina.php?' + params)
68 .then(() => location.href = 'index.html')
69 .catch(muestraError)
70 }">
71 Eliminar
72 </button>
73
74 </p>
75
76 </form>
77
78</body>
79
80</html>
skip_previous skip_next