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/invocaServicio.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 | <script type="module" src="lib/js/confirmaEliminar.js"></script> |
16 | <script type="module" src="lib/js/imagenSeleccionada.js"></script> |
17 | |
18 | <script> |
19 | |
20 | const params = new URL(location.href).searchParams |
21 | </script> |
22 | |
23 | </head> |
24 | |
25 | <body onload="if (params.size > 0) { |
26 | invocaServicio('srv/srvProductoBusca.php?' + params) |
27 | .then(modelo => muestraObjeto(document, modelo.body)) |
28 | .catch(muestraError) |
29 | }"> |
30 | |
31 | <form onsubmit="submitForm('srv/srvProductoModifica.php', event) |
32 | .then(modelo => location.href = 'index.html') |
33 | .catch(muestraError)"> |
34 | |
35 | <h1>Modificar</h1> |
36 | |
37 | <p><a href="index.html">Cancelar</a></p> |
38 | |
39 | <input type="hidden" name="id"> |
40 | |
41 | <p> |
42 | <label> |
43 | Nombre * |
44 | <input name="nombre" value="Cargando…"> |
45 | </label> |
46 | </p> |
47 | |
48 | <p> |
49 | <label> |
50 | Imagen |
51 | <input name="bytes" type="file" accept="image/*" |
52 | oninput="imagenSeleccionada(this, imagen).catch(muestraError)"> |
53 | </label> |
54 | </p> |
55 | |
56 | <p>* Obligatorio</p> |
57 | |
58 | <p> |
59 | |
60 | <button type="submit">Guardar</button> |
61 | |
62 | <button type="button" onclick="if (params.size > 0 && confirmaEliminar()) { |
63 | invocaServicio('srv/srvProductoElimina.php?' + params) |
64 | .then(() => location.href = 'index.html') |
65 | .catch(muestraError) |
66 | }"> |
67 | Eliminar |
68 | </button> |
69 | |
70 | </p> |
71 | |
72 | <figure> |
73 | <img id="imagen" hidden alt="Imagen del producto" style="max-width: 100%;" |
74 | data-input="bytes"> |
75 | </figure> |
76 | |
77 | </form> |
78 | |
79 | </body> |
80 | |
81 | </html> |