| 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="js/lib/manejaErrores.js"></script> |
| 12 | |
| 13 | </head> |
| 14 | |
| 15 | <body> |
| 16 | |
| 17 | <form id="formulario""> |
| 18 |
|
| 19 | <h1>Agregar</h1> |
| 20 |
|
| 21 | <p><a href=" index.html">Cancelar</a></p> |
| 22 |
|
| 23 | <p> |
| 24 | <label> |
| 25 | Nombre * |
| 26 | <input name="nombre"> |
| 27 | </label> |
| 28 | </p> |
| 29 |
|
| 30 | <p> |
| 31 | <label> |
| 32 | Imagen * |
| 33 | <input name="imagen" type="file" accept="image/*"> |
| 34 | </label> |
| 35 | </p> |
| 36 |
|
| 37 | <p>* Obligatorio</p> |
| 38 |
|
| 39 | <p><button type="submit">Agregar</button></p> |
| 40 |
|
| 41 | <figure> |
| 42 | <img id="preview" hidden alt="Imagen del producto" style="max-width: 100%;"> |
| 43 | </figure> |
| 44 |
|
| 45 | </form> |
| 46 |
|
| 47 | <script type="module"> |
| 48 |
|
| 49 | import { submitAccion } from "./js/lib/submitAccion.js" |
| 50 | import { |
| 51 | muestraImagenSeleccionada |
| 52 | } from "./js/lib/muestraImagenSeleccionada.js" |
| 53 |
|
| 54 | formulario.addEventListener( |
| 55 | "submit", |
| 56 | event => submitAccion( |
| 57 | event, "php/producto-agrega.php", formulario, "index.html" |
| 58 | ) |
| 59 | ) |
| 60 |
|
| 61 | formulario.imagen.addEventListener( |
| 62 | "input", |
| 63 | () => muestraImagenSeleccionada(formulario.imagen, preview) |
| 64 | ) |
| 65 | |
| 66 | muestraImagenSeleccionada(formulario.imagen, preview) |
| 67 | |
| 68 | </script> |
| 69 | </body> |
| 70 | |
| 71 | </html> |