| 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="js/lib/manejaErrores.js"></script> |
| 12 | |
| 13 | </head> |
| 14 | |
| 15 | <body> |
| 16 | |
| 17 | <form id="formulario"> |
| 18 | |
| 19 | <h1>Modificar</h1> |
| 20 | |
| 21 | <p><a href="carrito.html">Cancelar</a></p> |
| 22 | |
| 23 | <input type="hidden" name="prodId"> |
| 24 | |
| 25 | <p> |
| 26 | <label> |
| 27 | Producto |
| 28 | <output name="prodNombre"> |
| 29 | <progress max="100">Cargando…</progress> |
| 30 | </output> |
| 31 | </label> |
| 32 | </p> |
| 33 | |
| 34 | <p> |
| 35 | <label> |
| 36 | Precio |
| 37 | <output name="precio"> |
| 38 | <progress max="100">Cargando…</progress> |
| 39 | </output> |
| 40 | </label> |
| 41 | </p> |
| 42 | |
| 43 | <p> |
| 44 | <label> |
| 45 | Cantidad * |
| 46 | <input name="cantidad" type="number" min="0" step="0.01"> |
| 47 | </label> |
| 48 | </p> |
| 49 | |
| 50 | <p>* Obligatorio</p> |
| 51 | |
| 52 | <p> |
| 53 | |
| 54 | <button type="submit">Guardar</button> |
| 55 | |
| 56 | <button id="botonEliminar" type="button"> |
| 57 | Eliminar |
| 58 | </button> |
| 59 | |
| 60 | </p> |
| 61 | |
| 62 | </form> |
| 63 | |
| 64 | <script type="module"> |
| 65 | |
| 66 | import { descargaVista } from "./js/lib/descargaVista.js" |
| 67 | import { submitAccion } from "./js/lib/submitAccion.js" |
| 68 | import { accionElimina } from "./js/lib/accionElimina.js" |
| 69 | |
| 70 | const params = new URL(location.href).searchParams |
| 71 | descargaDatos() |
| 72 | |
| 73 | async function descargaDatos() { |
| 74 | |
| 75 | if (params.size > 0) { |
| 76 | |
| 77 | await descargaVista("php/vista-modifica.php?" + params) |
| 78 | |
| 79 | formulario.addEventListener( |
| 80 | "submit", |
| 81 | event => submitAccion( |
| 82 | event, "php/det-venta-modifica.php", formulario, "carrito.html" |
| 83 | ) |
| 84 | ) |
| 85 | |
| 86 | botonEliminar.addEventListener( |
| 87 | "click", |
| 88 | () => accionElimina( |
| 89 | "php/det-venta-elimina.php", |
| 90 | formulario, |
| 91 | "Confirma la eliminación", |
| 92 | "carrito.html" |
| 93 | ) |
| 94 | ) |
| 95 | |
| 96 | } |
| 97 | |
| 98 | } |
| 99 | |
| 100 | </script> |
| 101 | |
| 102 | </body> |
| 103 | |
| 104 | </html> |