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>Agregar</title> |
10 | |
11 | <script type="module" src="lib/js/submitForm.js"></script> |
12 | <script type="module" src="lib/js/muestraError.js"></script> |
13 | <script type="module" src="lib/js/muestraImagenSeleccionada.js"></script> |
14 | |
15 | </head> |
16 | |
17 | <body onload="muestraImagenSeleccionada(forma, forma.imagen) |
18 | .catch(muestraError)"> |
19 | |
20 | <form id="forma" onsubmit="submitForm('srv/producto-agrega.php', event) |
21 | .then(respuesta => location.href = 'index.html') |
22 | .catch(muestraError)"> |
23 | |
24 | <h1>Agregar</h1> |
25 | |
26 | <p><a href="index.html">Cancelar</a></p> |
27 | |
28 | <p> |
29 | <label> |
30 | Nombre * |
31 | <input name="nombre"> |
32 | </label> |
33 | </p> |
34 | |
35 | <p> |
36 | <label> |
37 | Imagen * |
38 | <input name="imagen" type="file" accept="image/*" data-img="preview" |
39 | oninput="muestraImagenSeleccionada(forma, this).catch(muestraError)"> |
40 | </label> |
41 | </p> |
42 | |
43 | <p>* Obligatorio</p> |
44 | |
45 | <p><button type="submit">Agregar</button></p> |
46 | |
47 | <figure> |
48 | <img id="preview" hidden alt="Imagen del producto" style="max-width: 100%;"> |
49 | </figure> |
50 | |
51 | </form> |
52 | |
53 | </body> |
54 | |
55 | </html> |