| 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="libclienteweb/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 { |
| 50 | configuraSubmitAccion |
| 51 | } from "./libclienteweb/configuraSubmitAccion.js" |
| 52 | import { |
| 53 | muestraImagenSeleccionada |
| 54 | } from "./libclienteweb/muestraImagenSeleccionada.js" |
| 55 | |
| 56 | configuraSubmitAccion("api/producto-agrega.php", formulario, "index.html") |
| 57 | formulario.imagen.addEventListener("input", muestraImagen) |
| 58 | muestraImagen() |
| 59 | |
| 60 | function muestraImagen() { |
| 61 | muestraImagenSeleccionada(formulario.imagen, preview) |
| 62 | } |
| 63 | |
| 64 | </script> |
| 65 | |
| 66 | </body> |
| 67 | |
| 68 | </html> |